This is needed by later patch when vpnd needs to remember the
previous used IP address.
---
include/ipaddress.h | 1 +
src/ipaddress.c | 25 +++++++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/include/ipaddress.h b/include/ipaddress.h
index c698541..3655ca8 100644
--- a/include/ipaddress.h
+++ b/include/ipaddress.h
@@ -51,6 +51,7 @@ void connman_ipaddress_set_peer(struct connman_ipaddress
*ipaddress,
void connman_ipaddress_clear(struct connman_ipaddress *ipaddress);
void connman_ipaddress_copy_address(struct connman_ipaddress *ipaddress,
struct connman_ipaddress *source);
+struct connman_ipaddress *connman_ipaddress_copy(struct connman_ipaddress
*ipaddress);
#ifdef __cplusplus
}
diff --git a/src/ipaddress.c b/src/ipaddress.c
index 95f9038..9892654 100644
--- a/src/ipaddress.c
+++ b/src/ipaddress.c
@@ -192,8 +192,7 @@ void connman_ipaddress_clear(struct connman_ipaddress
*ipaddress)
/*
* Note that this copy function only copies the actual address and
- * prefixlen. If you need full copy of ipaddress struct, then you need
- * to create a new function that does that.
+ * prefixlen. Use the other copy function to copy the whole struct.
*/
void connman_ipaddress_copy_address(struct connman_ipaddress *ipaddress,
struct connman_ipaddress *source)
@@ -207,3 +206,25 @@ void connman_ipaddress_copy_address(struct
connman_ipaddress *ipaddress,
g_free(ipaddress->local);
ipaddress->local = g_strdup(source->local);
}
+
+struct connman_ipaddress *
+connman_ipaddress_copy(struct connman_ipaddress *ipaddress)
+{
+ struct connman_ipaddress *copy;
+
+ if (!ipaddress)
+ return NULL;
+
+ copy = g_try_new0(struct connman_ipaddress, 1);
+ if (!copy)
+ return NULL;
+
+ copy->family = ipaddress->family;
+ copy->prefixlen = ipaddress->prefixlen;
+ copy->local = g_strdup(ipaddress->local);
+ copy->peer = g_strdup(ipaddress->peer);
+ copy->broadcast = g_strdup(ipaddress->broadcast);
+ copy->gateway = g_strdup(ipaddress->gateway);
+
+ return copy;
+}
--
1.8.3.1
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman