Added
Link Here
|
1 |
This reverts commit c371602f5f499a29d1fb1c43a8d12f21ff56296b. |
2 |
--- |
3 |
src/ifvc.c | 23 ++++++++++------------- |
4 |
1 file changed, 10 insertions(+), 13 deletions(-) |
5 |
|
6 |
diff --git a/src/ifvc.c b/src/ifvc.c |
7 |
index 3a7476d..2d487ed 100644 |
8 |
--- a/src/ifvc.c |
9 |
+++ b/src/ifvc.c |
10 |
@@ -34,13 +34,6 @@ |
11 |
|
12 |
#include "igmpproxy.h" |
13 |
|
14 |
-/* We need a temporary copy to not break strict aliasing rules */ |
15 |
-static inline uint32_t s_addr_from_sockaddr(const struct sockaddr *addr) { |
16 |
- struct sockaddr_in addr_in; |
17 |
- memcpy(&addr_in, addr, sizeof(addr_in)); |
18 |
- return addr_in.sin_addr.s_addr; |
19 |
-} |
20 |
- |
21 |
struct IfDesc IfDescVc[ MAX_IF ], *IfDescEp = IfDescVc; |
22 |
|
23 |
/* aimwang: add for detect interface and rebuild IfVc record */ |
24 |
@@ -112,15 +105,17 @@ void rebuildIfVc () { |
25 |
} |
26 |
|
27 |
// Get the interface adress... |
28 |
- Dp->InAdr.s_addr = s_addr_from_sockaddr(&IfPt->ifr_addr); |
29 |
+ Dp->InAdr = ((struct sockaddr_in *)&IfPt->ifr_addr)->sin_addr; |
30 |
addr = Dp->InAdr.s_addr; |
31 |
|
32 |
memcpy( IfReq.ifr_name, Dp->Name, sizeof( IfReq.ifr_name ) ); |
33 |
+ IfReq.ifr_addr.sa_family = AF_INET; |
34 |
+ ((struct sockaddr_in *)&IfReq.ifr_addr)->sin_addr.s_addr = addr; |
35 |
|
36 |
// Get the subnet mask... |
37 |
if (ioctl(Sock, SIOCGIFNETMASK, &IfReq ) < 0) |
38 |
my_log(LOG_ERR, errno, "ioctl SIOCGIFNETMASK for %s", IfReq.ifr_name); |
39 |
- mask = s_addr_from_sockaddr(&IfReq.ifr_netmask); |
40 |
+ mask = ((struct sockaddr_in *)&IfReq.ifr_addr)->sin_addr.s_addr; |
41 |
subnet = addr & mask; |
42 |
|
43 |
if ( ioctl( Sock, SIOCGIFFLAGS, &IfReq ) < 0 ) |
44 |
@@ -131,7 +126,7 @@ void rebuildIfVc () { |
45 |
{ |
46 |
if ( ioctl( Sock, SIOCGIFDSTADDR, &IfReq ) < 0 ) |
47 |
my_log(LOG_ERR, errno, "ioctl SIOCGIFDSTADDR for %s", IfReq.ifr_name); |
48 |
- addr = s_addr_from_sockaddr(&IfReq.ifr_dstaddr); |
49 |
+ addr = ((struct sockaddr_in *)&IfReq.ifr_dstaddr)->sin_addr.s_addr; |
50 |
subnet = addr & mask; |
51 |
} |
52 |
|
53 |
@@ -263,15 +258,17 @@ void buildIfVc(void) { |
54 |
} |
55 |
|
56 |
// Get the interface adress... |
57 |
- IfDescEp->InAdr.s_addr = s_addr_from_sockaddr(&IfPt->ifr_addr); |
58 |
+ IfDescEp->InAdr = ((struct sockaddr_in *)&IfPt->ifr_addr)->sin_addr; |
59 |
addr = IfDescEp->InAdr.s_addr; |
60 |
|
61 |
memcpy( IfReq.ifr_name, IfDescEp->Name, sizeof( IfReq.ifr_name ) ); |
62 |
+ IfReq.ifr_addr.sa_family = AF_INET; |
63 |
+ ((struct sockaddr_in *)&IfReq.ifr_addr)->sin_addr.s_addr = addr; |
64 |
|
65 |
// Get the subnet mask... |
66 |
if (ioctl(Sock, SIOCGIFNETMASK, &IfReq ) < 0) |
67 |
my_log(LOG_ERR, errno, "ioctl SIOCGIFNETMASK for %s", IfReq.ifr_name); |
68 |
- mask = s_addr_from_sockaddr(&IfReq.ifr_netmask); |
69 |
+ mask = ((struct sockaddr_in *)&IfReq.ifr_addr)->sin_addr.s_addr; |
70 |
subnet = addr & mask; |
71 |
|
72 |
/* get if flags |
73 |
@@ -293,7 +290,7 @@ void buildIfVc(void) { |
74 |
{ |
75 |
if ( ioctl( Sock, SIOCGIFDSTADDR, &IfReq ) < 0 ) |
76 |
my_log(LOG_ERR, errno, "ioctl SIOCGIFDSTADDR for %s", IfReq.ifr_name); |
77 |
- addr = s_addr_from_sockaddr(&IfReq.ifr_dstaddr); |
78 |
+ addr = ((struct sockaddr_in *)&IfReq.ifr_dstaddr)->sin_addr.s_addr; |
79 |
subnet = addr & mask; |
80 |
} |
81 |
|
82 |
-- |
83 |
2.15.1 |
84 |
|