added some dns code

This commit is contained in:
hyung-hwan 2019-02-11 09:24:16 +00:00
parent 3dcbd4a231
commit b40bdf3e8e
4 changed files with 87 additions and 13 deletions

View File

@ -23,13 +23,16 @@ include_HEADERS = \
mio-cfg.h \
mio-cmn.h \
mio-dns.h \
mio-pac1.h \
mio-pro.h \
mio-sck.h \
mio-upac.h \
mio-utl.h \
mio.h
lib_LTLIBRARIES = libmio.la
libmio_la_SOURCES = \
dns.c \
err.c \
fmtout.c \
fmtoutv.h \

View File

@ -140,12 +140,12 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
libmio_la_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1)
am_libmio_la_OBJECTS = libmio_la-err.lo libmio_la-fmtout.lo \
libmio_la-mio.lo libmio_la-mio-pro.lo libmio_la-mio-sck.lo \
libmio_la-sck-addr.lo libmio_la-sys.lo libmio_la-sys-ass.lo \
libmio_la-sys-err.lo libmio_la-sys-log.lo libmio_la-sys-mux.lo \
libmio_la-sys-tim.lo libmio_la-tmr.lo libmio_la-utf8.lo \
libmio_la-utl.lo
am_libmio_la_OBJECTS = libmio_la-dns.lo libmio_la-err.lo \
libmio_la-fmtout.lo libmio_la-mio.lo libmio_la-mio-pro.lo \
libmio_la-mio-sck.lo libmio_la-sck-addr.lo libmio_la-sys.lo \
libmio_la-sys-ass.lo libmio_la-sys-err.lo libmio_la-sys-log.lo \
libmio_la-sys-mux.lo libmio_la-sys-tim.lo libmio_la-tmr.lo \
libmio_la-utf8.lo libmio_la-utl.lo
libmio_la_OBJECTS = $(am_libmio_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -395,13 +395,16 @@ include_HEADERS = \
mio-cfg.h \
mio-cmn.h \
mio-dns.h \
mio-pac1.h \
mio-pro.h \
mio-sck.h \
mio-upac.h \
mio-utl.h \
mio.h
lib_LTLIBRARIES = libmio.la
libmio_la_SOURCES = \
dns.c \
err.c \
fmtout.c \
fmtoutv.h \
@ -576,6 +579,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-dns.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-err.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-fmtout.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmio_la-mio-pro.Plo@am__quote@
@ -617,6 +621,13 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libmio_la-dns.lo: dns.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-dns.lo -MD -MP -MF $(DEPDIR)/libmio_la-dns.Tpo -c -o libmio_la-dns.lo `test -f 'dns.c' || echo '$(srcdir)/'`dns.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-dns.Tpo $(DEPDIR)/libmio_la-dns.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dns.c' object='libmio_la-dns.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmio_la-dns.lo `test -f 'dns.c' || echo '$(srcdir)/'`dns.c
libmio_la-err.lo: err.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmio_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmio_la-err.lo -MD -MP -MF $(DEPDIR)/libmio_la-err.Tpo -c -o libmio_la-err.lo `test -f 'err.c' || echo '$(srcdir)/'`err.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmio_la-err.Tpo $(DEPDIR)/libmio_la-err.Plo

View File

@ -380,7 +380,7 @@ static int setup_arp_tester (mio_t* mio)
sck_make.on_read = arp_sck_on_read;
sck_make.on_connect = arp_sck_on_connect;
sck_make.on_disconnect = arp_sck_on_disconnect;
sck = mio_dev_sck_make (mio, 0, &sck_make);
sck = mio_dev_sck_make(mio, 0, &sck_make);
if (!sck)
{
printf ("Cannot make socket device\n");

View File

@ -66,25 +66,85 @@ enum mio_dns_rcode_t
};
typedef enum mio_dns_rcode_t mio_dns_rcode_t;
enum mio_dns_qtype_t
{
MIO_DNS_QTYPE_A = 1,
MIO_DNS_QTYPE_NS = 2,
MIO_DNS_QTYPE_CNAME = 5,
MIO_DNS_QTYPE_SOA = 6,
MIO_DNS_QTYPE_PTR = 12,
MIO_DNS_QTYPE_MX = 15,
MIO_DNS_QTYPE_TXT = 16,
MIO_DNS_QTYPE_AAAA = 28,
MIO_DNS_QTYPE_OPT = 41,
MIO_DNS_QTYPE_ANY = 255
};
typedef enum mio_dns_qtype_t mio_dns_qtype_t;
enum mio_dns_qclass_t
{
MIO_DNS_QCLASS_IN = 1, /* internet */
MIO_DNS_QCLASS_CH = 3, /* chaos */
MIO_DNS_QCLASS_HS = 4, /* hesiod */
MIO_DNS_QCLASS_NONE = 254,
MIO_DNS_QCLASS_ANY = 255
};
typedef enum mio_dns_qclass_t mio_dns_qclass_t;
#include <mio-pac1.h>
struct mio_dns_msg_t
{
mio_uint16_t id;
#if defined(MIO_ENDIAN_BIG)
mio_uint16_t qr: 1; /* query(0), answer(1) */
mio_uint16_t opcode: 4; /* operation type */
mio_uint16_t aa: 1; /* authoritative answer */
mio_uint16_t tc: 1; /* truncated. response too large for UDP */
mio_uint16_t rd: 1; /* recursion desired */
mio_uint16_t ra: 1; /* recursion available */
mio_uint16_t unused_1: 1;
mio_uint16_t ad: 1; /* authentication data - dnssec */
mio_uint16_t cd: 1; /* checking disabled - dnssec */
mio_uint16_t rcode: 4;
mio_uint16_t qdcount;
mio_uint16_t ancount;
mio_uint16_t nscount;
mio_uint16_t arcount;
};
#else
mio_uint16_t rd: 1;
mio_uint16_t tc: 1;
mio_uint16_t aa: 1;
mio_uint16_t opcode: 4;
mio_uint16_t qr: 1;
typedef struct mio_dns_msg_t mio-dns
mio_uint16_t rcode: 4;
mio_uint16_t cd: 1;
mio_uint16_t ad: 1;
mio_uint16_t unused_1: 1;
mio_uint16_t ra: 1;
#endif
mio_uint16_t qdcount; /* number of questions */
mio_uint16_t ancount; /* number of answers */
mio_uint16_t nscount; /* number of name servers */
mio_uint16_t arcount; /* number of additional resource */
};
typedef struct mio_dns_msg_t mio_dns_msg_t;
struct mio_dns_qdrechdr_t
{
mio_uint16_t qtype;
mio_uint16_t qclass;
};
typedef struct moo_dns_qdrechdr_t moo_dns_qdrechdr_t;
struct mio_dns_anrechdr_t
{
mio_uint16_t qtype;
mio_uint16_t qclass;
mio_uint32_t ttl;
mio_uint16_t dlen; /* data length */
};
typedef struct moo_dns_ansrechdr_t moo_dns_ansrechdr_t;
#include <mio-upac.h>
#endif