From 856d87db552cdc4ca373a922b07141274a4465d6 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 12 Apr 2019 03:53:32 +0000 Subject: [PATCH] touched up main.c to support more platforms --- mio/lib/main.c | 17 +++++++++-------- mio/lib/mio-sck.c | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mio/lib/main.c b/mio/lib/main.c index d93d1f4..51e7775 100644 --- a/mio/lib/main.c +++ b/mio/lib/main.c @@ -384,7 +384,7 @@ static int setup_arp_tester (mio_t* mio) sck = mio_dev_sck_make(mio, 0, &sck_make); if (!sck) { - printf ("Cannot make socket device\n"); + MIO_INFO1 (mio, "Cannot make arp socket device - %js\n", mio_geterrmsg(mio)); return -1; } @@ -411,7 +411,7 @@ static int setup_arp_tester (mio_t* mio) if (mio_dev_sck_write(sck, ðarp, MIO_SIZEOF(etharp), MIO_NULL, ðdst) <= -1) //if (mio_dev_sck_write (sck, ðarp.arphdr, MIO_SIZEOF(etharp) - MIO_SIZEOF(etharp.ethhdr), MIO_NULL, ðaddr) <= -1) { - printf ("CANNOT WRITE ARP...\n"); + MIO_INFO1 (mio, "Cannot write arp - %js\n", mio_geterrmsg(mio)); } @@ -433,6 +433,7 @@ static int schedule_icmp_wait (mio_dev_sck_t* dev); static void send_icmp (mio_dev_sck_t* dev, mio_uint16_t seq) { + mio_t* mio = dev->mio; mio_sckaddr_t dstaddr; mio_ip4addr_t ia; mio_icmphdr_t* icmphdr; @@ -452,13 +453,13 @@ static void send_icmp (mio_dev_sck_t* dev, mio_uint16_t seq) if (mio_dev_sck_write(dev, buf, MIO_SIZEOF(buf), MIO_NULL, &dstaddr) <= -1) { - printf ("CANNOT WRITE ICMP...\n"); + MIO_INFO1 (mio, "Cannot write icmp - %js\n", mio_geterrmsg(mio)); mio_dev_sck_halt (dev); } if (schedule_icmp_wait (dev) <= -1) { - printf ("CANNOT SCHEDULE ICMP WAIT...\n"); + MIO_INFO1 (mio, "Cannot schedule icmp wait - %js\n", mio_geterrmsg(mio)); mio_dev_sck_halt (dev); } } @@ -474,7 +475,7 @@ static void on_icmp_due (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* tmrjo if (icmpxtn->reply_received) icmpxtn->reply_received = 0; else - printf ("NO ICMP REPLY RECEIVED....\n"); + MIO_INFO0 (mio, "NO IMCP reply received in time\n"); send_icmp (dev, ++icmpxtn->icmp_seq); } @@ -584,7 +585,7 @@ static int setup_ping4_tester (mio_t* mio) sck = mio_dev_sck_make (mio, MIO_SIZEOF(icmpxtn_t), &sck_make); if (!sck) { - printf ("Cannot make ICMP4 socket device\n"); + MIO_INFO1 (mio, "Cannot make ICMP4 socket device - %js\n", mio_geterrmsg(mio)); return -1; } @@ -774,8 +775,8 @@ int main (int argc, char* argv[]) //mio_dev_sck_sendfile (tcp[2], fd, offset, count); - if (setup_arp_tester(mio) <= -1) goto oops; - if (setup_ping4_tester(mio) <= -1) goto oops; + setup_arp_tester(mio); + setup_ping4_tester(mio); #if 1 for (i = 0; i < 5; i++) diff --git a/mio/lib/mio-sck.c b/mio/lib/mio-sck.c index 2e55059..842db6c 100644 --- a/mio/lib/mio-sck.c +++ b/mio/lib/mio-sck.c @@ -317,14 +317,14 @@ static struct sck_type_map_t sck_type_map[] = /* MIO_DEV_SCK_ARP - Ethernet type is 2 bytes long. Protocol must be specified in the network byte order */ { AF_PACKET, SOCK_RAW, MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP), 0 }, - /* MIO_DEV_SCK_DGRAM */ + /* MIO_DEV_SCK_ARP_DGRAM */ { AF_PACKET, SOCK_DGRAM, MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP), 0 }, #elif defined(AF_LINK) && (MIO_SIZEOF_STRUCT_SOCKADDR_DL > 0) /* MIO_DEV_SCK_ARP */ { AF_LINK, SOCK_RAW, MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP), 0 }, - /* MIO_DEV_SCK_DGRAM */ + /* MIO_DEV_SCK_ARP_DGRAM */ { AF_LINK, SOCK_DGRAM, MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP), 0 }, #else { -1, 0, 0, 0 },