On Tue, 2008-01-22 at 22:13 +0100, Guido Serassio wrote:
> ACLARP.cc: In function `int aclMatchArp(SplayNode<acl_arp_data*>**, 
> IPAddress&)':
> ACLARP.cc:571: error: no matching function for call to
> `in_addr::in_addr(DWORD&)'
> d:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/winsock2.h:223: 
> note: candidates are: in_addr::in_addr()
> d:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/winsock2.h:223: 
> note:                 in_addr::in_addr(const in_addr&)
> make[3]: *** [ACLARP.o] Error 1
> 
> I'm not able to do the correct type cast, please do you can help me ?

in_addr is a C structure without a constructor so you cannot cast an
integer to it. The structure has a single member of uint32_t type. If
that type is the same as DWORD, then you can do C tricks with pointers,
converting DWORD address into in_addr address and then dereferencing it
for comparison with the "c" object. I do not know whether those tricks
are kosher alignment-wise.

Alternatively, you can decompose the structure to initialize it, like
the following code does. There is probably a cleaner way to do it.

--- ACLARP.cc   20 Jan 2008 17:23:19 -0000      1.27
+++ ACLARP.cc   22 Jan 2008 21:52:40 -0000
@@ -568,7 +568,9 @@
 
     /* Find MAC address from net table */
     for (i = 0 ; i < NetTable->dwNumEntries ; i++) {
-        if ((c == (struct in_addr)NetTable->table[i].dwAddr) && 
(NetTable->table[i].dwType > 2)) {
+        in_addr a;
+        a.s_addr = NetTable->table[i].dwAddr;
+        if (c == a && (NetTable->table[i].dwType > 2)) {
             arpReq.arp_ha.sa_family = AF_UNSPEC;
             memcpy(arpReq.arp_ha.sa_data, NetTable->table[i].bPhysAddr, 
NetTable->table[i].dwPhysAddrLen);
         }

HTH,

Alex.


Reply via email to