int natt_process_natd(struct ikev2_sa *ike_sa, struct ikev2payl_notify *n, int use_spi_r) { unsigned int type; uint8_t *n_data = NULL; rc_vchar_t *hash = NULL; struct sockaddr *addr = NULL; int ret; type = get_notify_type(n); n_data = get_notify_data(n); switch (type) { case IKEV2_NAT_DETECTION_SOURCE_IP: addr = ike_sa->remote; break; case IKEV2_NAT_DETECTION_DESTINATION_IP: addr = ike_sa->local; break; default: plog(PLOG_DEBUG, PLOGLOC, NULL, "invalid notify type\n"); plog(PLOG_DEBUG, PLOGLOC, NULL, "type=%u\n", type); return -1; } hash = natt_create_hash(&ike_sa->index, addr, use_spi_r); if (hash == NULL) { return -1; } ret = memcmp(n_data, hash->v, hash->l); rc_vfree(hash); switch (type) { case IKEV2_NAT_DETECTION_SOURCE_IP: if (ret != 0) { ike_sa->peer_behind_nat = TRUE; } else { ike_sa->peer_behind_nat = FALSE; } break; case IKEV2_NAT_DETECTION_DESTINATION_IP: if (ret != 0) { ike_sa->behind_nat = TRUE; if (ike_sa->natk_timer) { SCHED_KILL(ike_sa->natk_timer); } ike_sa->natk_timer = sched_new(ikev2_natk_interval(ike_sa->rmconf), natt_natk_callback, ike_sa); if (ike_sa->natk_timer == NULL) { plog(PLOG_INTERR, PLOGLOC, NULL, "failed to rc_vmalloc for natk_timer\n"); return -1; } } else { ike_sa->behind_nat = FALSE; } break; default: plog(PLOG_DEBUG, PLOGLOC, NULL, "invalid notify type\n"); plog(PLOG_DEBUG, PLOGLOC, NULL, "type=%d\n", type); return -1; } return 0; }
/********************************************************************* * @fn performPeriodicTask * * @brief Perform a periodic application task. This function gets * called every five seconds as a result of the SBP_PERIODIC_EVT * OSAL event. In this example, the value of the third * characteristic in the SimpleGATTProfile service is retrieved * from the profile, and then copied into the value of the * the fourth characteristic. * * @param none * * @return none */ static void performPeriodicTask( void ) { static uint16 hub_buzzer_count = 0; extern uint16 buzzer_on_time; // WD_KICK(); // 喂狗, 避免软件重启 if(control_buzzer_flag == 1)//蜂鸣器响的时间控制 { hub_buzzer_count++; if(hub_buzzer_count > buzzer_on_time) { hub_buzzer_count = 0; control_buzzer_flag = 0; buzzer_control(0); } } if(last_report_get_ack_flag == REPORT_START) { report_count++; if(report_count == report_countnum)//50*100 = 5s { report_count = 0; //重新开始计算时间 report_countnum = report_countnumN; report_timeout_count++; if(report_timeout_count < 120) // 5*12*10s = 10分钟 { immediatly_report_flag = 1; } else { report_timeout_count = 0; last_report_get_ack_flag = REPORT_ACK_TIMEOUT; Rf470_setfre1(); //超时设置为频点一,转为接收模式 } } } else { report_count = 0; } PeriodtimeCnt1++; if(PeriodtimeCnt1 == UpdateNotifityTimeN) { uint8 data = 0; PeriodtimeCnt1 = 0; data = get_notify_data(); //battery and lock state report char4_notify(data); } PeriodtimeCnt2++; //LED blinks if(PeriodtimeCnt2<LedLightTimeN) { HalLedSet (HAL_LED_3, HAL_LED_MODE_OFF); } else if(PeriodtimeCnt2<LedUnlightTimeN) { HalLedSet (HAL_LED_3, HAL_LED_MODE_OFF); } else { PeriodtimeCnt2=0; } // SysTick1++; // if(SysTick1 >= 200) //睡眠2s时间到 // { // SysTick1 =0; // LSD_RF_WOR_Execute(1); //启动CAD采样一次 // } // // SysTick2++; // if(SysTick2 >= 600) //睡眠6s时间到 // { // SysTick2 =0; // OFF_Timerout(); //关闭超时定时器 // LSD_RF_WORInit(); //WOR初始化 // LSD_RF_WOR_Execute(0); //启动执行WOR // } }