1/************************************************************/ 2/* Version 1.4 by Yuhsin_Lee 2005/1/19 16:31 */ 3/************************************************************/ 4 5#include <stdio.h> //sprintf function 6#include <memory.h> //memset function 7#include <string.h> //strncpy function 8#include <stdlib.h> //strtoul function 9 10#include "packet.h" 11 12// AP: 13// PackGetInfoCurrentAP : Send command to get current setting of AP 14// UnpackGetInfoCurrentAP : Parse response to get current setting of AP 15// PackSetInfoCurrentAP : Send command to set current setting of AP 16// UnpackSetInfoCurrentAP : Parse reponse to set current setting of AP 17// 18// WB: 19// PackGetInfoCurrentSTA : Send command to get current setting of station 20// UnpackGetInfoCurrentSTA : Parse response to get current setting of station 21// PackGetInfoSites : Send command to get site survey result 22// UnpackGetInfoSites : Parse reponse to get site survey result 23// PackSetInfoCurrentSTA : Send command to set current setting of station 24// UnpackSetInfoCurrentSTA : Parse response to set current setting of station 25// PackGetInfoProfileSTA : Send command to get profile 26// UnpackGetInfoProfileSTA : Parse reponse to get profile 27// PackSetInfoProfiles : Send command to set profile 28// UnpackSetInfoProfileSTA : Send command to set profile 29 30DWORD transID=1; 31 32DWORD GetTransactionID(void) 33{ 34 transID++; 35 36 if (transID==0) transID=1; 37 38 return transID; 39} 40 41void PackKey(int keytype, char *keystr, char *key1, char *key2, char *key3, char *key4) 42{ 43 int i, j; 44 char tmp[3]; 45 46 memset(keystr, 0, 64); 47 48 if (keytype == ENCRYPTION_WEP64) 49 { 50 j=5; 51 } 52 else 53 { 54 j=13; 55 } 56 57 for(i=0;i<j;i++) 58 { 59 strncpy(tmp, key1+i*2, 2); 60 tmp[2] = 0; 61 keystr[i] = strtoul(tmp, 0, 16); 62 } 63 for(i=0;i<j;i++) 64 { 65 strncpy(tmp, key2+i*2, 2); 66 tmp[2] = 0; 67 keystr[i+16] = strtoul(tmp, 0, 16); 68 } 69 for(i=0;i<j;i++) 70 { 71 strncpy(tmp, key3+i*2, 2); 72 tmp[2] = 0; 73 keystr[i+32] = strtoul(tmp, 0, 16); 74 } 75 for(i=0;i<j;i++) 76 { 77 strncpy(tmp, key4+i*2, 2); 78 tmp[2] = 0; 79 keystr[i+48] = strtoul(tmp, 0, 16); 80 } 81} 82 83int UnpackGetInfo(char *pdubuf, PKT_GET_INFO *Info) 84{ 85 IBOX_COMM_PKT_RES *hdr; 86 87 hdr = (IBOX_COMM_PKT_RES *)pdubuf; 88 89 if (hdr->ServiceID!=NET_SERVICE_ID_IBOX_INFO || //0x0C 12 90 hdr->PacketType!=NET_PACKET_TYPE_RES || //0x16 22 91 hdr->OpCode!=NET_CMD_ID_GETINFO) //0x1F 31 92 return (RESPONSE_HDR_IGNORE); 93 94 // save after the header 95 memcpy(Info, pdubuf+sizeof(IBOX_COMM_PKT_RES), sizeof(PKT_GET_INFO)); 96 97 return(RESPONSE_HDR_OK); 98} 99 100int UnpackGetInfo_NEW(char *pdubuf, PKT_GET_INFO *discoveryInfo, STORAGE_INFO_T *storageInfo) 101{ 102 IBOX_COMM_PKT_RES *hdr; 103 104 hdr = (IBOX_COMM_PKT_RES *)pdubuf; 105 106 if (hdr->ServiceID != NET_SERVICE_ID_IBOX_INFO || //0x0C 12 107 hdr->PacketType != NET_PACKET_TYPE_RES || //0x16 22 108 hdr->OpCode != NET_CMD_ID_GETINFO) //0x1F 31 109 return (RESPONSE_HDR_IGNORE); 110 111 // get discovery info 112 memcpy(discoveryInfo, pdubuf+sizeof(IBOX_COMM_PKT_RES), sizeof(PKT_GET_INFO)); 113 114 STORAGE_INFO_T *tempStorageInfo = (STORAGE_INFO_T *)(pdubuf + sizeof(IBOX_COMM_PKT_RES) + sizeof(PKT_GET_INFO) + sizeof(WS_INFO_T)); 115 116 if (tempStorageInfo->MagicWord != EXTEND_MAGIC) // 0x8082 32898 117 return (RESPONSE_HDR_OK); 118 119 if ((tempStorageInfo->ExtendCap & EXTEND_CAP_WEBDAV) != EXTEND_CAP_WEBDAV) // 0x0001 1 120 return (RESPONSE_HDR_OK); 121 122 memcpy(storageInfo, tempStorageInfo, sizeof(STORAGE_INFO_T)); 123 124 if ((tempStorageInfo->ExtendCap & EXTEND_CAP_AAE_BASIC) != EXTEND_CAP_AAE_BASIC) // 0x0010 16 125 return (RESPONSE_HDR_OK_SUPPORT_WEBDAV); 126 127 return (RESPONSE_HDR_OK_SUPPORT_WEBDAV_TUNNEL); 128}