/* * Initialize the various elements in the MAC layer. Reset the protocol * control block, start the mac process, init the events, and set the mac * info base to its default values. */ void mac_init() { mac_queue_init(); mac_indir_init(); mac_scan_init(); /* * Set up the processes. First start the mac process, * then allocate the rx event */ process_start(&mac_process, NULL); event_mac_rx = process_alloc_event(); /* init the pcb */ memset(&pcb, 0, sizeof(mac_pcb_t)); /* init the mac pib */ memset(&pib, 0, sizeof(mac_pib_t)); pib.ack_wait_duration = aMacAckWaitDuration; pib.resp_wait_time = aMacResponseWaitTime; pib.coord_addr.mode = SHORT_ADDR; pib.coord_addr.short_addr = 0xFFFF; pib.short_addr = 0xFFFF; pib.pan_id = 0xFFFF; pib.rx_on_when_idle = true; pib.assoc_permit = true; pib.max_csma_backoffs = 3; pib.min_be = 3; pib.dsn = (U8)drvr_get_rand(); #if (TEST_SIM == 1) pib.ext_addr = getpid(); #else pib.ext_addr = drvr_get_rand(); #endif /* set these in the hardware */ drvr_set_pan_id(pib.pan_id); drvr_set_short_addr(pib.short_addr); drvr_set_ext_addr(pib.ext_addr); }
void mac_init() { mac_queue_init(); mac_indir_init(); mac_scan_init(); // Set up the processes. // First start the mac process, then allocate the rx event process_start(&mac_process, NULL); event_mac_rx = process_alloc_event(); // init the pcb memset(&pcb, 0, sizeof(mac_pcb_t)); // init the mac pib memset(&pib, 0, sizeof(mac_pib_t)); pib.ack_wait_duration = aMacAckWaitDuration; pib.resp_wait_time = aMacResponseWaitTime; pib.coord_addr.mode = SHORT_ADDR; pib.coord_addr.short_addr = 0xFFFF; pib.short_addr = 0xFFFF; pib.pan_id = 0xFFFF; pib.rx_on_when_idle = true; pib.assoc_permit = true; pib.max_csma_backoffs = 3; pib.min_be = 3; pib.dsn = (U8)drvr_get_rand(); #if (TEST_SIM == 1) //lint -e{732} Info 732: Loss of sign (assignment) (int to unsigned long long) pib.ext_addr = getpid(); #else pib.ext_addr = drvr_get_rand(); #endif // set these in the hardware drvr_set_pan_id(pib.pan_id); drvr_set_short_addr(pib.short_addr); drvr_set_ext_addr(pib.ext_addr); }