Пример #1
0
 /**
  * @brief 触发用户事件,用于执行 启用/禁用上网
  * @return true 表示执行成功 false 表示执行失败
  */
 public function allow_internet_access($ip)
 {
     $len = 0;
     if (!parent::pack_write_u8(IPCService::WTM_IPC_VERSION)) {
         return FALSE;
     }
     if (!parent::pack_write_u8(IPCService::WTM_COMM_SWITCH_INTERNET_ACCESS)) {
         return FALSE;
     }
     if (!parent::pack_write_u32(ip2long($ip))) {
         return FALSE;
     }
     \Util::log_warn(__METHOD__ . ' ' . "allow_internet_access success()!");
     return TRUE;
 }
Пример #2
0
 public function query()
 {
     if (!parent::pack_write_u8(IPCService::WTM_IPC_VERSION)) {
         return FALSE;
     }
     if (!parent::pack_write_u8(IPCService::WTM_COMM_REALTIME_STAT_QUERY)) {
         return FALSE;
     }
     if (!parent::pack_write_u8(IPCService::WTM_RTS_OVERVIEW_QUERY)) {
         return FALSE;
     }
     if (parent::read_unpack_u8() != IPCService::WTM_IPC_VERSION) {
         return FALSE;
     }
     if (parent::read_unpack_u8() != IPCService::WTM_COMM_REALTIME_STAT_REPLY) {
         return FALSE;
     }
     if (parent::read_unpack_u8() != IPCService::WTM_RTS_OVERVIEW_REPLY) {
         return FALSE;
     }
     $count = parent::read_unpack_u32();
     if ($count === FALSE) {
         return FALSE;
     }
     for ($i = 0; $i < $count; $i++) {
         $attribute_type = parent::read_unpack_u16();
         if ($this->attributes_length[$attribute_type] == 1) {
             $this->attributes[$attribute_type] = parent::read_unpack_u8();
         } else {
             if ($this->attributes_length[$attribute_type] == 2) {
                 $this->attributes[$attribute_type] = parent::read_unpack_u16();
             } else {
                 if ($this->attributes_length[$attribute_type] == 4) {
                     $this->attributes[$attribute_type] = parent::read_unpack_u32();
                 } else {
                     if ($this->attributes_length[$attribute_type] == 8) {
                         $this->attributes[$attribute_type] = parent::read_unpack_u64();
                     }
                 }
             }
         }
     }
     return $this->attributes;
 }