diff --git a/src/connectivity/libipsecims/utils_xfrm.c b/src/connectivity/libipsecims/utils_xfrm.c
new file mode 100644
index 0000000..178a19b
--- /dev/null
+++ b/src/connectivity/libipsecims/utils_xfrm.c
@@ -0,0 +1,230 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <resolv.h>
+#include <asm/types.h>
+#include <linux/pkt_sched.h>
+#include <time.h>
+#include <sys/time.h>
+#include <errno.h>
+#include "utils_xfrm.h"
+#define LOG_TAG "setkey"
+#include <log/log.h>
+#include <cutils/log.h>
+
+
+int mask2bits(__u32 netmask_xfrm)
+{
+	unsigned bits_xfrm = 0;
+	__u32 mask_xfrm = ntohl(netmask_xfrm);
+	__u32 host_xfrm = ~mask_xfrm;
+
+	/* a valid netmask must be 2^n - 1 */
+	if ((host_xfrm & (host_xfrm + 1)) != 0)
+		return -1;
+
+	for (; mask_xfrm; mask_xfrm <<= 1)
+		++bits_xfrm;
+	return bits_xfrm;
+}
+
+int get_netmask(unsigned *val_xfrm, const char *arg_xfrm, int base_xfrm)
+{
+	inet_prefix addr_xfrm;
+
+	if (!get_unsigned(val_xfrm, arg_xfrm, base_xfrm))
+		return 0;
+
+	/* try coverting dotted quad to CIDR */
+	if (!get_addr_1(&addr_xfrm, arg_xfrm, AF_INET) && addr_xfrm.family == AF_INET) {
+		int b_xfrm = mask2bits(addr_xfrm.data[0]);
+
+		if (b_xfrm >= 0) {
+			*val_xfrm = b_xfrm;
+			return 0;
+		}
+	}
+
+	return -1;
+}
+
+int get_unsigned(unsigned *val_xfrm, const char *arg_xfrm, int base_xfrm)
+{
+	unsigned long res_xfrm = 0;
+	char *ptr_xfrm = NULL;
+
+	if (!arg_xfrm || !*arg_xfrm)
+		return -1;
+	res_xfrm = strtoul(arg_xfrm, &ptr_xfrm, base_xfrm);
+	if (!ptr_xfrm || ptr_xfrm == arg_xfrm || *ptr_xfrm || res_xfrm > UINT_MAX)
+		return -1;
+	*val_xfrm = res_xfrm;
+	return 0;
+}
+
+
+int get_u32(__u32 *val_xfrm, const char *arg_xfrm, int base_xfrm)
+{
+	unsigned long res_xfrm = 0;
+	char *ptr_xfrm = NULL;
+
+	if (!arg_xfrm || !*arg_xfrm)
+		return -1;
+	res_xfrm = strtoul(arg_xfrm, &ptr_xfrm, base_xfrm);
+	if (!ptr_xfrm || ptr_xfrm == arg_xfrm || *ptr_xfrm || res_xfrm > 0xFFFFFFFFUL)
+		return -1;
+	*val_xfrm = res_xfrm;
+	return 0;
+}
+
+
+int get_u8(__u8 *val_xfrm, const char *arg_xfrm, int base_xfrm)
+{
+	unsigned long res_xfrm = 0;
+	char *ptr_xfrm = NULL;
+
+	if (!arg_xfrm || !*arg_xfrm)
+		return -1;
+	res_xfrm = strtoul(arg_xfrm, &ptr_xfrm, base_xfrm);
+	if (!ptr_xfrm || ptr_xfrm == arg_xfrm || *ptr_xfrm || res_xfrm > 0xFF)
+		return -1;
+	*val_xfrm = res_xfrm;
+	return 0;
+}
+
+
+
+/* This uses a non-standard parsing (ie not inet_aton, or inet_pton)
+ * because of legacy choice to parse 10.8 as 10.8.0.0 not 10.0.0.8
+ */
+int get_addr_ipv4(__u8 *ap_xfrm, const char *cp_xfrm)
+{
+	int i_xfrm = 0;
+
+	for (i_xfrm = 0; i_xfrm < 4; i_xfrm++) {
+		unsigned long n_xfrm = 0;
+		char *endp_xfrm = NULL;
+
+		n_xfrm = strtoul(cp_xfrm, &endp_xfrm, 0);
+		if (n_xfrm > 255)
+			return -1;	/* bogus network value */
+
+		if (endp_xfrm == cp_xfrm) /* no digits */
+			return -1;
+
+		ap_xfrm[i_xfrm] = n_xfrm;
+
+		if (*endp_xfrm == '\0')
+			break;
+
+		if (i_xfrm == 3 || *endp_xfrm != '.')
+			return -1; 	/* extra characters */
+		cp_xfrm = endp_xfrm + 1;
+	}
+
+	return 1;
+}
+
+int get_addr_1(inet_prefix *addr_xfrm, const char *name_xfrm, int family)
+{
+	memset(addr_xfrm, 0, sizeof(*addr_xfrm));
+
+	if (strcmp(name_xfrm, "default") == 0 ||
+	    strcmp(name_xfrm, "all") == 0 ||
+	    strcmp(name_xfrm, "any") == 0) {
+		if (family == AF_DECnet)
+			return -1;
+		addr_xfrm->family = family;
+		addr_xfrm->bytelen = (family == AF_INET6 ? 16 : 4);
+		addr_xfrm->bitlen = -1;
+		return 0;
+	}
+
+	if (strchr(name_xfrm, ':')) {
+		addr_xfrm->family = AF_INET6;
+		if (family != AF_UNSPEC && family != AF_INET6)
+			return -1;
+		if (inet_pton(AF_INET6, name_xfrm, addr_xfrm->data) <= 0)
+			return -1;
+		addr_xfrm->bytelen = 16;
+		addr_xfrm->bitlen = -1;
+		return 0;
+	}
+
+
+	addr_xfrm->family = AF_INET;
+	if (family != AF_UNSPEC && family != AF_INET)
+		return -1;
+
+	if (get_addr_ipv4((__u8 *)addr_xfrm->data, name_xfrm) <= 0)
+		return -1;
+
+	addr_xfrm->bytelen = 4;
+	addr_xfrm->bitlen = -1;
+	return 0;
+}
+
+int get_prefix(inet_prefix *dst_xfrm, char *arg_xfrm, int family)
+{
+	int err = 0 ;
+	unsigned plen  = 0;
+	char *slash = NULL;
+
+	memset(dst_xfrm, 0, sizeof(*dst_xfrm));
+
+	if (strcmp(arg_xfrm, "default") == 0 ||
+	    strcmp(arg_xfrm, "any") == 0 ||
+	    strcmp(arg_xfrm, "all") == 0) {
+		if (family == AF_DECnet)
+			return -1;
+		dst_xfrm->family = family;
+		dst_xfrm->bytelen = 0;
+		dst_xfrm->bitlen = 0;
+		return 0;
+	}
+
+	slash = strchr(arg_xfrm, '/');
+	if (slash)
+		*slash = 0;
+
+	err = get_addr_1(dst_xfrm, arg_xfrm, family);
+	if (err == 0) {
+		switch(dst_xfrm->family) {
+			case AF_INET6:
+				dst_xfrm->bitlen = 128;
+				break;
+			case AF_DECnet:
+				dst_xfrm->bitlen = 16;
+				break;
+			default:
+			case AF_INET:
+				dst_xfrm->bitlen = 32;
+		}
+		if (slash) {
+			if (get_netmask(&plen, slash+1, 0)
+					|| plen > dst_xfrm->bitlen) {
+				err = -1;
+				goto done;
+			}
+			dst_xfrm->flags |= PREFIXLEN_SPECIFIED;
+			dst_xfrm->bitlen = plen;
+		}
+	}
+done:
+	if (slash)
+		*slash = '/';
+	return err;
+}
+
+
+
+
+
