summaryrefslogtreecommitdiffstats
path: root/clatd.h
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2019-04-08 17:46:48 -0700
committerMaciej Żenczykowski <maze@google.com>2019-05-08 21:02:19 -0700
commit8addcc0f6360cc3762e9ef27437ded250e785da3 (patch)
treeac9a90d6280e22785aaca68db210bf5612ea1b13 /clatd.h
parent3297c7d7bca85db2b178e8838138b71e9d2a86ad (diff)
downloadplatform_external_android-clat-android10-qpr2-s2-release.tar.gz
platform_external_android-clat-android10-qpr2-s2-release.tar.bz2
platform_external_android-clat-android10-qpr2-s2-release.zip
Test: atest clatd_test, built and installed on aosp_blueline device connected to ipv6-only wifi network: ping 8.8.8.8 still works and it is via v4-wlan0 clat tun interface Bug: 65674744 Bug: 131268436 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I8c9e235e9a5bf1a1436e8dc3af8d0aa86f6dc1a5 Merged-In: I8c9e235e9a5bf1a1436e8dc3af8d0aa86f6dc1a5 (cherry picked from commit 716518d9b9ca52182498b1d7ed0f0ed8ab42cbe1)
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__ */