Files
BLV_C1F_Module/BasicCode/Drive/NET/DNS.h

99 lines
3.0 KiB
C
Raw Normal View History

#ifndef _DNS_H_
#define _DNS_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "CH57x_common.h"
#include "net.h"
#define MAX_URL_SIZE 128
#define MAX_DNS_BUF_SIZE 256 /*DNS<4E><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󳤶<EFBFBD> */
#define CH563NET_DBG 1 /* printf<74><66><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> */
#define SERVER_NAME_DNS "www.boonlive-rcu.com"
#define TFTPSERVER_NAME_DNS "blv-tftp-log.blv-oa.com" //"BoonliveNAS.synology.me"
#define UDPSERVER_NAME_DNS "rcu-udp-svr.blv-oa.com"
/*
********************************************************************************
Define Part
********************************************************************************
*/
#define TYPE_A 1 /* Host address */
#define TYPE_NS 2 /* Name server */
#define TYPE_MD 3 /* Mail destination (obsolete) */
#define TYPE_MF 4 /* Mail forwarder (obsolete) */
#define TYPE_CNAME 5 /* Canonical name */
#define TYPE_SOA 6 /* Start of Authority */
#define TYPE_MB 7 /* Mailbox name (experimental) */
#define TYPE_MG 8 /* Mail group member (experimental) */
#define TYPE_MR 9 /* Mail rename name (experimental) */
#define TYPE_NULL 10 /* Null (experimental) */
#define TYPE_WKS 11 /* Well-known sockets */
#define TYPE_PTR 12 /* Pointer record */
#define TYPE_HINFO 13 /* Host information */
#define TYPE_MINFO 14 /* Mailbox information (experimental)*/
#define TYPE_MX 15 /* Mail exchanger */
#define TYPE_TXT 16 /* Text strings */
#define TYPE_ANY 255 /* Matches any type */
#define CLASS_IN 1 /* The ARPA Internet */
typedef enum
{
DNS_INIT,
DNS_INIT1,
DNS_DATA_SEND,
DNS_WAIT_RECV,
DNS_ANALYSIS,
DNS_ClOSE,
}DNS_STA;
struct dhdr
{
UINT16 id; /* <20><>ʶ */
UINT8 qr; /* <20><>ѯ<EFBFBD><D1AF>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>־*/
UINT8 opcode;
UINT8 aa; /* <20><>Ȩ<EFBFBD>ش<EFBFBD> */
UINT8 tc; /* <20>ɽضϵ<D8B6> */
UINT8 rd; /* <20><><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>*/
UINT8 ra; /* <20><><EFBFBD>Եݹ<D4B5> */
UINT8 rcode; /* Ӧ<><D3A6><EFBFBD><EFBFBD> */
UINT16 qdcount; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
UINT16 ancount; /* Ӧ<><D3A6><EFBFBD><EFBFBD> */
UINT16 nscount; /* <20><>Ȩ<EFBFBD><C8A8> */
UINT16 arcount; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC> */
};
//extern UINT8 dns_buf[MAX_DNS_BUF_SIZE];
extern UINT8* dns_buf;
extern UINT8 DNS_SERVER_IP[4];
UINT16 get16(UINT8 * s);
int ParseName(UINT8 * msg, UINT8 * compressed, char * buf);
UINT8 * DnsQuestion(UINT8 * msg, UINT8 * cp);
UINT8 * DnsAnswer(UINT8 * msg, UINT8 * cp, UINT8 * pSip);
UINT8 parseMSG(struct dhdr * pdhdr, UINT8 * pbuf, UINT8 * pSip);
UINT8 * put16(UINT8 * s, UINT16 i);
UINT16 MakeDnsQueryMsg(UINT16 op, char * name, UINT8 * buf, UINT16 len);
//UINT8 DnsQuery(UINT8 s, UINT8 * name, UINT8 * pSip);
//UINT8 DnsQuery(UINT8 s, UINT8 * name, UINT8 * pSip);
UINT8 DnsQuery2(UINT8* s, UINT8 * name, UINT8 * pSip);
void UDPSocketParamInit(UINT8 sockindex,UINT8 *addr,UINT16 SourPort,UINT16 DesPort);
UINT8 DnsQuery_Task(UINT8* s, UINT8 * name, UINT8 * pSip);
#endif