summaryrefslogtreecommitdiffstats
path: root/clatd.h
diff options
context:
space:
mode:
authorMaciej enczykowski <maze@google.com>2019-05-10 01:11:21 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-10 01:11:21 -0700
commitc6125e3fa6d14b1ccd80b18850e961b4c4e5b4a5 (patch)
treeac9a90d6280e22785aaca68db210bf5612ea1b13 /clatd.h
parentef38b0dc2e2f964b2d6b17de65bf79a7867bef73 (diff)
parent8addcc0f6360cc3762e9ef27437ded250e785da3 (diff)
downloadplatform_external_android-clat-android10-qpr1-c-release.tar.gz
platform_external_android-clat-android10-qpr1-c-release.tar.bz2
platform_external_android-clat-android10-qpr1-c-release.zip
am: 8addcc0f63 Change-Id: I7f983ba1b6d54d70db1f2fdec35e38984c7c4388
Diffstat (limited to 'clatd.h')
-rw-r--r--clatd.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/clatd.h b/clatd.h
index f7f7315..d3869bf 100644
--- a/clatd.h
+++ b/clatd.h
@@ -18,6 +18,7 @@
#ifndef __CLATD_H__
#define __CLATD_H__
+#include <stdlib.h>
#include <sys/uio.h>
struct tun_data;
@@ -45,6 +46,27 @@ int configure_clat_ipv6_address(const struct tun_data *tunnel, const char *inter
void configure_interface(const char *uplink_interface, const char *plat_prefix, const char *v4_addr,
const char *v6, struct tun_data *tunnel, unsigned net_id);
void event_loop(struct tun_data *tunnel);
-int parse_unsigned(const char *str, unsigned *out);
+
+/* function: parse_int
+ * parses a string as a decimal/hex/octal signed integer
+ * str - the string to parse
+ * out - the signed integer to write to, gets clobbered on failure
+ */
+static inline int parse_int(const char *str, int *out) {
+ char *end_ptr;
+ *out = strtol(str, &end_ptr, 0);
+ return *str && !*end_ptr;
+}
+
+/* function: parse_unsigned
+ * parses a string as a decimal/hex/octal unsigned integer
+ * str - the string to parse
+ * out - the unsigned integer to write to, gets clobbered on failure
+ */
+static inline int parse_unsigned(const char *str, unsigned *out) {
+ char *end_ptr;
+ *out = strtoul(str, &end_ptr, 0);
+ return *str && !*end_ptr;
+}
#endif /* __CLATD_H__ */