From 3374c8b1c8396310cee571e195ec7915aa6c400e Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 30 Mar 2007 09:21:48 +0000 Subject: using IFA_LOCAL for interface enumeration to support ppp links --- src/charon/threads/kernel_interface.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/charon/threads/kernel_interface.c') diff --git a/src/charon/threads/kernel_interface.c b/src/charon/threads/kernel_interface.c index f8456abbb..e674e18b2 100644 --- a/src/charon/threads/kernel_interface.c +++ b/src/charon/threads/kernel_interface.c @@ -729,24 +729,39 @@ static linked_list_t *create_address_list(private_kernel_interface_t *this) size_t rtasize = IFA_PAYLOAD (hdr); host_t *host = NULL; char *name = NULL; - chunk_t chunk; + chunk_t local = chunk_empty, address = chunk_empty; while(RTA_OK(rta, rtasize)) { switch (rta->rta_type) { + case IFA_LOCAL: + local.ptr = RTA_DATA(rta); + local.len = RTA_PAYLOAD(rta); + break; case IFA_ADDRESS: - chunk.ptr = RTA_DATA(rta); - chunk.len = RTA_PAYLOAD(rta); - host = host_create_from_chunk(msg->ifa_family, - chunk, 0); + address.ptr = RTA_DATA(rta); + address.len = RTA_PAYLOAD(rta); break; case IFA_LABEL: name = RTA_DATA(rta); + break; } rta = RTA_NEXT(rta, rtasize); } + /* For PPP interfaces, we need the IFA_LOCAL address, + * IFA_ADDRESS is the peers address. But IFA_LOCAL is + * not included in all cases, so fallback to IFA_ADDRESS. */ + if (local.ptr) + { + host = host_create_from_chunk(msg->ifa_family, local, 0); + } + else if (address.ptr) + { + host = host_create_from_chunk(msg->ifa_family, address, 0); + } + if (host) { address_entry_t *entry; -- cgit v1.2.3