unsigned long currTime = 0;
unsigned long authCode = 668346822;
unsigned short customerID = 3098;
unsigned short customerVersion = 12624;
int num = 0;
unsigned char tmpBuf[64];
void* pTemp = NULL;
pTemp = ddnsMain_p->challengeStr + 6; /*ddnsMain_p->challengeStr 为一个unsigned char 数组*/
currTime = *((unsigned long* )pTemp);
/*debug Philip.Liu China 2007-03-23*/
DDNS_TRACE("peanutAuth() the time:/n%u/n",currTime);
num = (currTime / 30) % 32;
authCode = (~authCode) | (~currTime);
authCode = (authCode << (32 - num)) | (authCode >> num);
/*debug Philip.Liu China 2007-03-23*/
DDNS_TRACE("peanutAuth() the authcode:/n%u/n",authCode);
pTemp = tmpBuf + tmpLen;
*((unsigned long* )pTemp) = authCode;
tmpLen += 4;
pTemp = tmpBuf + tmpLen;
*((unsigned short*)pTemp) = customerID;
tmpLen += 2;
pTemp = tmpBuf + tmpLen;
*((unsigned short* )pTemp) = customerVersion;
tmpLen += 2;
ddnsMain_p是一个结构体类型
typedef struct ddnsMain_s {
uint16 flags;
/* define SP_DDNS_DDNS_ORG 0x01
define SP_DDNS_DYNDNS_ORG 0x02
define SP_DDNS_TZO_COM 0x03 */
uint16 serviceType;
int state; /* state */
int substate;
int retCode;
ip4a ipAddr; /* dns ip address */
#ifdef DDNS_HTTP
ip4a proxyAddr; /* proxy address */
uint16 proxyPort; /* proxy port */
uint8 proxySet; /* proxy set flag */
#endif
uint32 pauseTime;
uint32 tcpWaitTime;
tm_id_t timerID;
int socketID;
struct sockaddr_in socket;
uint32 transID;
uint16 port; /* destination port */
uint16 lPort; /* local port */
uint8 user[USER_NAME_LEN]; /* 32 */
uint8 password[USER_PSWD_LEN]; /* 32 */
uint8 eMail[SP_EMAIL_LEN]; /* 64 */
#ifdef NEW_GUI
#ifdef DDNS_HTTP
uint8 serverAddress[SERVER_ADDRESS_LEN]; /* 64 */
uint8 serverMode; /* ddns Server mode: Provider default or User defined */
void * wcRequestPtr;
uint16 timeout;
uint8 token[OUT_USER_NAME_LEN];
uint8 salt[11];
uint8 time[11];
uint8 sign[33];
uint8 reqc;
uint8 reqNum;
#endif
uint8 domainName[OUT_USER_NAME_LEN*3+2]; /* 3 host(64 char len) + 2 ',' comma */
uint8 ddnsType; /* dynamin, static, or custom */
#else
uint8 domainName[OUT_USER_NAME_LEN]; /* 64 */
#endif
uint32 successCnt;
uint32 startcnt;
uint32 stopcnt;
uint32 retrycnt;
uint32 retryTime;
struct iface_s *ifp;
uint32 lastUpdateTime;
#ifdef DDNS_PEANUT
int32 sessNo;
uint32 seqNoOrig;
uint8 challengeStr[32];
int challengeStrLen;
uint8 sendBuf[20];
uint32 udpWaitTime;
int udpSocketID;
struct sockaddr_in udpSocket;
struct sockaddr_in udpLocalSin;
struct sockaddr_in localSin;
uint32 kaFailCnt;
#endif
} ddnsMain_t; /* ddnsMain_t */