1/************************************************************/
2/*  Version 1.4     by Yuhsin_Lee 2005/1/19 16:31           */
3/************************************************************/
4
5#ifndef packetH
6#define packetH
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include "iboxcom.h"
13
14// constants for regulatory domain
15#define FCC				(0x10)  //channel 1-11
16//#define CANADA			(0x20)  //channel 1-11 => just use FCC
17#define ETSI			(0x30)  //channel 1-13
18//#define SPAIN				(0x31)  //channel 10-11
19//#define FRANCE			(0x32)  //channel 10-13
20//#define MKK				(0x40)  //channel 14
21#define MKK1			(0xff)  //channel 1-14
22
23#define MIN_FCC         (1)
24#define MAX_FCC         (11)
25
26#define MIN_ETSI        (1)
27#define MAX_ETSI        (13)
28
29/*
30#define MIN_SPAIN       (10)
31#define MAX_SPAIN       (11)
32
33#define MIN_FRANCE      (10)
34#define MAX_FRANCE      (13)
35
36#define MIN_MKK         (14)
37#define MAX_MKK         (14)
38*/
39
40#define MIN_MKK1        (1)
41#define MAX_MKK1        (14)
42
43// Internal error message
44enum  RESPOSNE_HDR
45{
46	RESPONSE_HDR_OK = 0,
47	RESPONSE_HDR_IGNORE,
48	RESPONSE_HDR_ERR_PASSWORD,
49	RESPONSE_HDR_ERR_TID,
50	RESPONSE_HDR_ERR_UNSUPPORT,
51    RESPONSE_HDR_OK_SUPPORT_WEBDAV,
52    RESPONSE_HDR_OK_SUPPORT_WEBDAV_TUNNEL
53};
54
55enum  WAITING_FUNCTION
56{
57	UNPACK_GET_INFO = 0,
58	UNPACK_GET_INFO_CURRENT_AP,
59	UNPACK_SET_INFO_CURRENT_AP,
60	UNPACK_GET_INFO_CURRENT_STA,
61	UNPACK_GET_INFO_SITES,
62	UNPACK_SET_INFO_CURRENT_STA,
63	UNPACK_GET_INFO_PROFILES,
64	UNPACK_SET_INFO_PROFILES,
65	UNPACK_CHECK_PASSWORD,
66	UNPACK_SysCmdRes,
67	NONE
68};
69
70enum COMM_STATE_ENUM
71{
72	COMM_STATE_IDLE = 0x00,
73	COMM_STATE_WAIT
74};
75
76enum WEP_STATE
77{
78	WEP_DISABLED = 0x00,
79	WEP_ENABLED
80};
81
82//---------------------------------------------------------------------------
83
84//Header
85int UnpackResHdr(char *pdubuf, WORD opcode, DWORD tid, char *mac);
86
87// discovery:
88int PackGetInfo(char *pdubuf);
89int UnpackGetInfo(char *pdubuf, PKT_GET_INFO *Info);
90int PackGetInfo_NEW(char *pdubuf);
91int UnpackGetInfo_NEW(char *pdubuf, PKT_GET_INFO *discoveryInfo, STORAGE_INFO_T *storageInfo);
92
93// AP:
94int PackGetInfoCurrentAP(char *pdubuf, char *mac, char *password);
95int UnpackGetInfoCurrentAP(char *pdubuf, DWORD tid, char *mac, PKT_GET_INFO_AP *curAP);
96int PackSetInfoCurrentAP(char *pdubuf, char *mac, char *password, PKT_GET_INFO_AP *curAP);
97int UnpackSetInfoCurrentAP(char *pdubuf, DWORD tid, char *mac);
98
99// WB:
100int PackGetInfoCurrentSTA(char *pdubuf, char *mac, char *password);
101int UnpackGetInfoCurrentSTA(char *pdubuf, DWORD tid, char *mac, PKT_GET_INFO_STA *curSTA);
102int PackGetInfoSites(char *pdubuf, char *mac, char *password);
103int UnpackGetInfoSites(char *pdubuf, DWORD tid, char *mac, PKT_GET_INFO_SITES *sites);
104int PackSetInfoCurrentSTA(char *pdubuf, char *mac, char *password, PKT_GET_INFO_STA *curSTA);
105int UnpackSetInfoCurrentSTA(char *pdubuf, DWORD tid, char *mac);
106int PackGetInfoProfiles(char *pdubuf, char *mac, char *password, int start, int count);
107int UnpackGetInfoProfiles(char *pdubuf, DWORD tid, char *mac, PKT_GET_INFO_PROFILE *profile);
108int PackSetInfoProfiles(char *pdubuf, char *mac, char *password, PKT_GET_INFO_PROFILE *profile);
109int UnpackSetInfoProfiles(char *pdubuf, DWORD tid, char *mac);
110
111// WEP key
112void PackKey(int keytype, char *keystr, char *key1, char *key2, char *key3, char *key4);
113void UnpackKey(int keytype, char *keystr, char *key1, char *key2, char *key3, char *key4);
114
115// check password
116int PackCheckPassword(char *pdubuf, char *mac, char *password);
117int UnpackCheckPassword(char *pdubuf, DWORD tid, char *mac);
118
119//others
120int PackSysCmd(char *pdubuf, char *mac, char *password, PKT_SYSCMD *cmd);
121int UnpackSysCmdRes(char *pdubuf, DWORD tid, char *mac, PKT_SYSCMD_RES *sysres);
122
123// EZSetup
124int UnpackEZProbeRes(char *pdubuf, DWORD tid, char *mac, PKT_EZPROBE_INFO *info, char *key, int klen);
125int PackSetPubKey(char *pdubuf, char *mac, char *password, PKT_SET_INFO_GW_QUICK_KEY *key);
126int UnpackSetPubKeyRes(char *pdubuf, DWORD tid, char *mac, PKT_SET_INFO_GW_QUICK_KEY *key);
127int PackEZProbe(char *pdubuf, char *mac, char *password, char *key, int klen);
128int UnpackEZProbeRes(char *pdubuf, DWORD tid, char *mac, PKT_EZPROBE_INFO *info, char *key, int klen);
129int PackSetInfoGWQuick(char *pdubuf, char *mac, char *password, PKT_SET_INFO_GW_QUICK *setting, char *key, int klen);
130int UnpackSetInfoGWQuickRes(char *pdubuf, DWORD tid, char *mac, PKT_SET_INFO_GW_QUICK *setting, char *key, int klen);
131
132// ENCRYPTION
133void Encrypt(int klen, unsigned char *key, unsigned char *ptext, int tlen, unsigned char *ctext);
134void Decrypt(int klen, unsigned char *key, unsigned char *ptext, int tlen, unsigned char *ctext);
135//---------------------------------------------------------------------------
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif//#ifndef packetH
142
143