From adc1e694ff00cd96141db96a5b054913c668d6a1 Mon Sep 17 00:00:00 2001 From: Ajay Nambi Date: Thu, 26 May 2011 10:12:11 -0600 Subject: LibC definitions for missing elements needed for networking * Implementations for getprotobyname and getprotobynumber. * Add enable_flow flag for PRIO qdisc Change-Id: Ic9facd002e54a19c97ed9ae5e51e97dcdccad1cf --- libc/bionic/stubs.c | 37 +++++++++++++++++++++++++++++++++--- libc/kernel/common/linux/pkt_sched.h | 1 + 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libc/bionic/stubs.c b/libc/bionic/stubs.c index d495674..e943e9e 100644 --- a/libc/bionic/stubs.c +++ b/libc/bionic/stubs.c @@ -341,7 +341,7 @@ getgrnam(const char *name) struct netent* getnetbyname(const char *name) { - fprintf(stderr, "FIX ME! implement getgrnam() %s:%d\n", __FILE__, __LINE__); + fprintf(stderr, "FIX ME! implement getnetbyname() %s:%d\n", __FILE__, __LINE__); return NULL; } @@ -373,15 +373,46 @@ struct netent *getnetbyaddr(uint32_t net, int type) return NULL; } +// Android doesn't have /etc/protocols. Use this minimal list. +struct protoent protocols[] = { + {"ip", {"IP", NULL}, 0}, + {"icmp", {"ICMP", NULL}, 1}, + {"tcp", {"TCP", NULL}, 6}, + {"udp", {"UDP", NULL}, 17}, + {NULL, {NULL}, 0} +}; + struct protoent *getprotobyname(const char *name) { - fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + int i = 0; + + while (name && protocols[i].p_name != 0) + { + if (strcmp(protocols[i].p_name, name) == 0) + { + return &protocols[i]; + } + + i++; + } + return NULL; } struct protoent *getprotobynumber(int proto) { - fprintf(stderr, "FIX ME! implement %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + int i = 0; + + while (protocols[i].p_name != 0) + { + if (protocols[i].p_proto == proto) + { + return &protocols[i]; + } + + i++; + } + return NULL; } diff --git a/libc/kernel/common/linux/pkt_sched.h b/libc/kernel/common/linux/pkt_sched.h index 0b2966a..992a7a3 100644 --- a/libc/kernel/common/linux/pkt_sched.h +++ b/libc/kernel/common/linux/pkt_sched.h @@ -95,6 +95,7 @@ struct tc_prio_qopt { int bands; __u8 priomap[TC_PRIO_MAX+1]; + __u8 enable_flow; }; struct tc_multiq_qopt { -- cgit v1.1