From 9478f322c2b506fe9b3afc2e70ad67fefc8ee698 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 7 May 2011 21:38:27 +0800 Subject: [PATCH] IPStack - Misc cleanups - IPv6 fiddling - Fixed some const-ness --- Modules/IPStack/ipstack.h | 4 ++-- Modules/IPStack/ipv6.c | 2 +- Modules/IPStack/main.c | 16 ++++++++-------- Modules/IPStack/tcp.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Modules/IPStack/ipstack.h b/Modules/IPStack/ipstack.h index b0dff231..2076d5a7 100644 --- a/Modules/IPStack/ipstack.h +++ b/Modules/IPStack/ipstack.h @@ -116,8 +116,8 @@ static const tMacAddr cMAC_BROADCAST = {{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}}; extern int IPStack_AddFile(tSocketFile *File); extern int IPStack_GetAddressSize(int AddressType); -extern int IPStack_CompareAddress(int AddressType, void *Address1, void *Address2, int CheckBits); -extern const char *IPStack_PrintAddress(int AddressType, void *Address); +extern int IPStack_CompareAddress(int AddressType, const void *Address1, const void *Address2, int CheckBits); +extern const char *IPStack_PrintAddress(int AddressType, const void *Address); extern tRoute *IPStack_FindRoute(int AddressType, tInterface *Interface, void *Address); diff --git a/Modules/IPStack/ipv6.c b/Modules/IPStack/ipv6.c index d728325f..ed599238 100644 --- a/Modules/IPStack/ipv6.c +++ b/Modules/IPStack/ipv6.c @@ -169,7 +169,7 @@ void IPv6_int_GetPacket(tAdapter *Adapter, tMacAddr From, int Length, void *Buff hdr->HopLimit --; rt = IPStack_FindRoute(6, NULL, &hdr->Destination); // Get the route (gets the interface) - //to = ARP_Resolve6(rt->Interface, hdr->Destination); // Resolve address + to = ICMP6_ResolveHWAddr(rt->Interface, hdr->Destination); // Resolve address // Send packet Log_Log("IPv6", "Forwarding packet"); diff --git a/Modules/IPStack/main.c b/Modules/IPStack/main.c index 63499952..5aa67152 100644 --- a/Modules/IPStack/main.c +++ b/Modules/IPStack/main.c @@ -26,7 +26,7 @@ extern tRoute *IPStack_AddRoute(const char *Interface, void *Network, int Subnet // === PROTOTYPES === int IPStack_Install(char **Arguments); - int IPStack_CompareAddress(int AddressType, void *Address1, void *Address2, int CheckBits); + int IPStack_CompareAddress(int AddressType, const void *Address1, const void *Address2, int CheckBits); // === GLOBALS === MODULE_DEFINE(0, VERSION, IPStack, IPStack_Install, NULL, NULL); @@ -218,17 +218,17 @@ int IPStack_GetAddressSize(int AddressType) /** * \brief Compare two IP Addresses masked by CheckBits */ -int IPStack_CompareAddress(int AddressType, void *Address1, void *Address2, int CheckBits) +int IPStack_CompareAddress(int AddressType, const void *Address1, const void *Address2, int CheckBits) { int size = IPStack_GetAddressSize(AddressType); Uint8 mask; - Uint8 *addr1 = Address1, *addr2 = Address2; + const Uint8 *addr1 = Address1, *addr2 = Address2; // Sanity check size if( CheckBits < 0 ) CheckBits = 0; if( CheckBits > size*8 ) CheckBits = size*8; - if( CheckBits == 0 ) return 1; // /0 matches anythin0 + if( CheckBits == 0 ) return 1; // /0 matches anything // Check first bits/8 bytes if( memcmp(Address1, Address2, CheckBits/8) != 0 ) return 0; @@ -244,20 +244,20 @@ int IPStack_CompareAddress(int AddressType, void *Address1, void *Address2, int return 0; } -const char *IPStack_PrintAddress(int AddressType, void *Address) +const char *IPStack_PrintAddress(int AddressType, const void *Address) { switch( AddressType ) { case 4: { static char ret[4*3+3+1]; - Uint8 *addr = Address; + const Uint8 *addr = Address; sprintf(ret, "%i.%i.%i.%i", addr[0], addr[1], addr[2], addr[3]); return ret; } - case 6: { + case 6: { // TODO: address compression static char ret[8*4+7+1]; - Uint16 *addr = Address; + const Uint16 *addr = Address; sprintf(ret, "%x:%x:%x:%x:%x:%x:%x:%x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7] diff --git a/Modules/IPStack/tcp.c b/Modules/IPStack/tcp.c index cedb8ce7..83a71b64 100644 --- a/Modules/IPStack/tcp.c +++ b/Modules/IPStack/tcp.c @@ -18,7 +18,7 @@ #define TCP_RECIEVE_BUFFER_SIZE 0x4000 // === PROTOTYPES === -void TCP_Initialise(); +void TCP_Initialise(void); void TCP_StartConnection(tTCPConnection *Conn); void TCP_SendPacket(tTCPConnection *Conn, size_t Length, tTCPHeader *Data); void TCP_GetPacket(tInterface *Interface, void *Address, int Length, void *Buffer); @@ -62,7 +62,7 @@ Uint32 gaTCP_PortBitmap[0x800]; * * Registers the client and server files and the GetPacket callback */ -void TCP_Initialise() +void TCP_Initialise(void) { IPStack_AddFile(&gTCP_ServerFile); IPStack_AddFile(&gTCP_ClientFile); -- 2.20.1