This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
getifaddrs() and PPP
- From: Kelvin Lawson <klawson at ad-holdings dot co dot uk>
- To: ecos-patches at sources dot redhat dot com
- Date: Thu, 10 Jun 2004 17:16:48 +0100
- Subject: getifaddrs() and PPP
Hi Folks,
I've attached a patch for getifaddrs() to enable support for P2P
destination addresses.
At the moment it finds PPP interfaces, but does not return the
destination address. This patch calls the relevant IOCTL to get the
destination address. According to the reference for getifaddrs(), this
is what should happen:
"ifa_dstaddr - References the destination address on a P2P interface, if
one exists, otherwise it is NULL."
Cheers,
Kelvin.
diff -r -u5 -N -x CVS -x '*~' -x '.#*' clean/ecos/packages/net/common/current/ChangeLog devo/ecos/packages/net/common/current/ChangeLog
--- clean/ecos/packages/net/common/current/ChangeLog 2004-06-10 16:45:18.484375000 +0100
+++ devo/ecos/packages/net/common/current/ChangeLog 2004-06-10 16:45:27.687500000 +0100
@@ -1,5 +1,9 @@
+2004-06-10 Kelvin Lawson <klawson@ad-holdings.co.uk>
+
+ * src/ifaddrs.c: Return destination address for P2P interfaces
+
2004-06-08 Andrew Lunn <andrew.lunn@ascom.ch>
* include/network.h: Added a __THROW to perror so that it matches
what is in stdio.h. Problem pointed out by Øyvid Harboe.
diff -r -u5 -N -x CVS -x '*~' -x '.#*' clean/ecos/packages/net/common/current/src/ifaddrs.c devo/ecos/packages/net/common/current/src/ifaddrs.c
--- clean/ecos/packages/net/common/current/src/ifaddrs.c 2003-09-16 23:05:06.000000000 +0100
+++ devo/ecos/packages/net/common/current/src/ifaddrs.c 2004-06-10 16:40:01.984375000 +0100
@@ -199,10 +199,11 @@
data += SA_RLEN(sa);
if ((sa->sa_family == AF_INET) || (sa->sa_family == AF_INET6)) {
struct sockaddr *sa_netmask = NULL;
struct sockaddr *sa_broadcast = NULL;
+ struct sockaddr *sa_dst = NULL;
memset(&ifrq,0,sizeof(ifrq));
strcpy(ifrq.ifr_name,ifr->ifr_name);
ioctl( sock, SIOCGIFFLAGS, &ifrq );
@@ -225,19 +226,34 @@
#endif
ift->ifa_netmask = (struct sockaddr *)data;
memcpy(data, sa_netmask, SA_LEN(sa_netmask));
data += SA_RLEN(sa_netmask);
- memcpy(&ifrq.ifr_addr, ift->ifa_addr,sizeof(struct sockaddr));
- if (sa->sa_family == AF_INET) {
- if (ioctl(sock, SIOCGIFBRDADDR, &ifrq) == 0) {
- sa_broadcast = &ifrq.ifr_addr;
- ift->ifa_broadaddr = (struct sockaddr *)data;
- memcpy(data, sa_broadcast, SA_LEN(sa_broadcast));
- data += SA_RLEN(sa_broadcast);
+ if (ift->ifa_flags & IFF_BROADCAST) {
+ memcpy(&ifrq.ifr_addr, ift->ifa_addr,sizeof(struct sockaddr));
+ if (sa->sa_family == AF_INET) {
+ if (ioctl(sock, SIOCGIFBRDADDR, &ifrq) == 0) {
+ sa_broadcast = &ifrq.ifr_addr;
+ ift->ifa_broadaddr = (struct sockaddr *)data;
+ memcpy(data, sa_broadcast, SA_LEN(sa_broadcast));
+ data += SA_RLEN(sa_broadcast);
+ }
+ }
+ }
+
+ if (ift->ifa_flags & IFF_POINTOPOINT) {
+ memcpy(&ifrq.ifr_addr, ift->ifa_addr,sizeof(struct sockaddr));
+ if (sa->sa_family == AF_INET) {
+ if (ioctl(sock, SIOCGIFDSTADDR, &ifrq) == 0) {
+ sa_dst = &ifrq.ifr_addr;
+ ift->ifa_dstaddr = (struct sockaddr *)data;
+ memcpy(data, sa_dst, SA_LEN(sa_dst));
+ data += SA_RLEN(sa_dst);
+ }
}
}
}
if (SA_LEN(sa) < sizeof(*sa))
ifr = (struct ifreq *)(((char *)sa) + sizeof(*sa));
else
ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));