Latest compatible version of Classicube from the original GitHub repository (https://github.com/ClassiCube/ClassiCube) that can be compiled on Classicube for PowerMac PPC running Mac OS X 10.4.
This commit is contained in:
57
third_party/dsiwifi/arm_host/source/nds/sgIP.h
vendored
Normal file
57
third_party/dsiwifi/arm_host/source/nds/sgIP.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef SGIP_H
|
||||
#define SGIP_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_memblock.h"
|
||||
#include "sgIP_sockets.h"
|
||||
#include "sgIP_Hub.h"
|
||||
#include "sgIP_IP.h"
|
||||
#include "sgIP_ARP.h"
|
||||
#include "sgIP_ICMP.h"
|
||||
#include "sgIP_TCP.h"
|
||||
#include "sgIP_UDP.h"
|
||||
#include "sgIP_DNS.h"
|
||||
#include "sgIP_DHCP.h"
|
||||
|
||||
extern unsigned long volatile sgIP_timems;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sgIP_Init();
|
||||
void sgIP_Timer(int num_ms);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
80
third_party/dsiwifi/arm_host/source/nds/sgIP_ARP.h
vendored
Normal file
80
third_party/dsiwifi/arm_host/source/nds/sgIP_ARP.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_ARP_H
|
||||
#define SGIP_ARP_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_memblock.h"
|
||||
#include "sgIP_Hub.h"
|
||||
|
||||
#define SGIP_ARP_FLAG_ACTIVE 0x0001
|
||||
#define SGIP_ARP_FLAG_HAVEHWADDR 0x0002
|
||||
|
||||
typedef struct SGIP_ARP_RECORD {
|
||||
unsigned short flags, retrycount;
|
||||
unsigned long idletime;
|
||||
sgIP_Hub_HWInterface * linked_interface;
|
||||
sgIP_memblock * queued_packet;
|
||||
int linked_protocol;
|
||||
unsigned long protocol_address;
|
||||
char hw_address[SGIP_MAXHWADDRLEN];
|
||||
} sgIP_ARP_Record;
|
||||
|
||||
|
||||
typedef struct SGIP_HEADER_ARP {
|
||||
unsigned short hwspace; // ethernet=1;
|
||||
unsigned short protocol;
|
||||
unsigned char hw_addr_len;
|
||||
unsigned char protocol_addr_len;
|
||||
unsigned short opcode; // request=1, reply=2
|
||||
unsigned char addresses[8+12]; // sender HW, sender Protocol, dest HW, dest Protocol
|
||||
} sgIP_Header_ARP;
|
||||
|
||||
#define SGIP_HEADER_ARP_BASESIZE 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sgIP_ARP_Init();
|
||||
extern void sgIP_ARP_Timer100ms();
|
||||
extern void sgIP_ARP_FlushInterface(sgIP_Hub_HWInterface * hw);
|
||||
|
||||
extern int sgIP_ARP_ProcessIPFrame(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb);
|
||||
extern int sgIP_ARP_ProcessARPFrame(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb);
|
||||
extern int sgIP_ARP_SendProtocolFrame(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb, unsigned short protocol, unsigned long destaddr);
|
||||
|
||||
extern int sgIP_ARP_SendARPResponse(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb);
|
||||
extern int sgIP_ARP_SendGratARP(sgIP_Hub_HWInterface * hw);
|
||||
extern int sgIP_ARP_SendARPRequest(sgIP_Hub_HWInterface * hw, int protocol, unsigned long protocol_addr);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
274
third_party/dsiwifi/arm_host/source/nds/sgIP_Config.h
vendored
Normal file
274
third_party/dsiwifi/arm_host/source/nds/sgIP_Config.h
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef SGIP_CONFIG_H
|
||||
#define SGIP_CONFIG_H
|
||||
|
||||
#define __LINUX_ERRNO_EXTENSIONS__
|
||||
#include <errno.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// General options - these control the core functionality of the stack.
|
||||
|
||||
// SGIP_USEDYNAMICMEMORY: Allows the stack to use memory as it needs it, via malloc()/free()
|
||||
// This option is extremely useful in environments where it can be used, as it prevents the
|
||||
// overhead of allocating per-connection memory in advance, and allows an unlimited number
|
||||
// of connections, provided the memory space. This option requires the implementation of
|
||||
// two C functions, "void * sgIP_malloc(int)" and "void sgIP_free(void *)", which behave
|
||||
// similarly to the malloc and free functions commonly used in C.
|
||||
#define SGIP_USEDYNAMICMEMORY
|
||||
|
||||
// SGIP_INTERRUPT_THREADING_MODEL: Provides memory protection in a system that can allow
|
||||
// multiple processing "threads" by way of interrupts. This is not required on single
|
||||
// threaded systems, and not adequate on multithreaded systems, but provides a way to
|
||||
// allow protection against contention on interrupt-driven systems. This option requires
|
||||
// the system to implement two C functions "int sgIP_DisableInterrupts()" and additionally
|
||||
// "void sgIP_RestoreInterrupts(int)" that takes as a parameter the value returned by
|
||||
// sgIP_DisableInterrupts(). Interrupts are disabled upon beginning work with sensitive
|
||||
// memory areas or allocation/deallocation of memory, and are restored afterwards.
|
||||
#define SGIP_INTERRUPT_THREADING_MODEL
|
||||
|
||||
// SGIP_MULTITHREADED_THREADING_MODEL: Standard memory protection for large multithreaded
|
||||
// systems, such as operating systems and the like. This kind of memory protection is
|
||||
// useful for true multithreaded systems but useless in a single-threaded system and
|
||||
// harmful in an interrupt-based multiprocess system.
|
||||
//#define SGIP_MULTITHREADED_THREADING_MODEL
|
||||
|
||||
#define SGIP_LITTLEENDIAN
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Temporary memory system settings
|
||||
|
||||
// SGIP_MEMBLOCK_DATASIZE: This is the maximum data size contained in a single sgIP_memblock.
|
||||
// for best performance ensure this value is larger than any packet that is expected to be
|
||||
// received, however, in a memory-tight situation, much smaller values can be used.
|
||||
#define SGIP_MEMBLOCK_DATASIZE 1600
|
||||
|
||||
// SGIP_MEMBLOCK_BASENUM: The starting number of memblocks that will be allocated. This is
|
||||
// also the total number of memblocks that will be allocated if sgIP is not configured to use
|
||||
// dynamic memory allocation.
|
||||
#define SGIP_MEMBLOCK_BASENUM 12
|
||||
|
||||
// SGIP_MEMBLOCK_STEPNUM: In the case that all memblocks are full, and dynamic memory is
|
||||
// enabled, this many additional memblocks will be allocated in an attempt to satasfy the
|
||||
// memory usage demands of the stack.
|
||||
#define SGIP_MEMBLOCK_STEPNUM 6
|
||||
|
||||
// SGIP_MEMBLOCK_DYNAMIC_MALLOC_ALL: Who cares what the other memblock defines say, let's
|
||||
// Generate all memblocks by mallocing 'em.
|
||||
#define SGIP_MEMBLOCK_DYNAMIC_MALLOC_ALL
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Hardware layer settings
|
||||
|
||||
// SGIP_MAXHWADDRLEN: The maximum usable hardware address length. Ethernet is 6 bytes.
|
||||
#define SGIP_MAXHWADDRLEN 8
|
||||
|
||||
// SGIP_MAXHWHEADER: The maximum allocated size for hardware headers.
|
||||
#define SGIP_MAXHWHEADER 16
|
||||
|
||||
// SGIP_MTU_OVERRIDE: This is the maximum MTU that will be accepted. By default it is being
|
||||
// set to 1460 bytes in order to be courteous to Ethernet and it's ridiculously low MTU.
|
||||
// This value will allow you to prevent fragmentation of IP packets by not using the full
|
||||
// MTU available to your network interface when the IP packet will just be sliced and diced
|
||||
// at the next smaller MTU. (the stack will still use HW mtu if it's lower.)
|
||||
#define SGIP_MTU_OVERRIDE 1460
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Connection settings - can be tuned to change memory usage and performance
|
||||
|
||||
// SGIP_TCP_STATELESS_LISTEN: Uses a technique to prevent syn-flooding from blocking listen
|
||||
// ports by using all the connection blocks/memory.
|
||||
#define SGIP_TCP_STATELESS_LISTEN
|
||||
|
||||
// SGIP_TCP_STEALTH: Only sends packets in response to connections to active ports. Doing so
|
||||
// causes ports to appear not as closed, but as if the deviced does not exist when probing
|
||||
// ports that are not in use.
|
||||
//#define SGIP_TCP_STEALTH
|
||||
|
||||
// SGIP_TCP_TTL: Time-to-live value given to outgoing packets, in the absence of a reason to
|
||||
// manually override this value.
|
||||
#define SGIP_IP_TTL 128
|
||||
|
||||
// SGIP_TCPRECEIVEBUFFERLENGTH: The size (in bytes) of the receive FIFO in a TCP connection
|
||||
#define SGIP_TCP_RECEIVEBUFFERLENGTH 8192
|
||||
|
||||
// SGIP_TCPTRANSMITBUFFERLENGTH: The size (in bytes) of the transmit FIFO in a TCP connection
|
||||
#define SGIP_TCP_TRANSMITBUFFERLENGTH 8192
|
||||
|
||||
// SGIP_TCPOOBBUFFERLENGTH: The size (in bytes) of the receive OOB data FIFO in a TCP connection
|
||||
#define SGIP_TCP_OOBBUFFERLENGTH 256
|
||||
|
||||
// SGIP_ARP_MAXENTRIES: The maximum number of cached ARP entries - this is defined staticly
|
||||
// because it's somewhat impractical to dynamicly allocate memory for such a small structure
|
||||
// (at least on most smaller systems)
|
||||
#define SGIP_ARP_MAXENTRIES 32
|
||||
|
||||
// SGIP_HUB_MAXHWINTERFACES: The maximum number of hardware interfaces the sgIP hub will
|
||||
// connect to. A hardware interface being some port (ethernet, wifi, etc) that will relay
|
||||
// packets to the outside world.
|
||||
#define SGIP_HUB_MAXHWINTERFACES 1
|
||||
|
||||
// SGIP_HUB_MAXPROTOCOLINTERFACES: The maximum number of protocol interfaces the sgIP hub will
|
||||
// connect to. A protocol interface being a software handler for a certain protocol type
|
||||
// (such as IP)
|
||||
#define SGIP_HUB_MAXPROTOCOLINTERFACES 1
|
||||
|
||||
#define SGIP_TCP_FIRSTOUTGOINGPORT 40000
|
||||
#define SGIP_TCP_LASTOUTGOINGPORT 65000
|
||||
#define SGIP_UDP_FIRSTOUTGOINGPORT 40000
|
||||
#define SGIP_UDP_LASTOUTGOINGPORT 65000
|
||||
|
||||
#define SGIP_TCP_GENTIMEOUTMS 6000
|
||||
#define SGIP_TCP_TRANSMIT_DELAY 25
|
||||
#define SGIP_TCP_TRANSMIT_IMMTHRESH 40
|
||||
#define SGIP_TCP_TIMEMS_2MSL 1000*60*2
|
||||
#define SGIP_TCP_MAXRETRY 7
|
||||
#define SGIP_TCP_MAXSYNS 64
|
||||
#define SGIP_TCP_REACK_THRESH 1000
|
||||
|
||||
#define SGIP_TCP_SYNRETRYMS 250
|
||||
#define SGIP_TCP_GENRETRYMS 500
|
||||
#define SGIP_TCP_BACKOFFMAX 6000
|
||||
|
||||
#define SGIP_SOCKET_MAXSOCKETS 32
|
||||
|
||||
//#define SGIP_SOCKET_DEFAULT_NONBLOCK 1
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// DNS settings
|
||||
|
||||
#define SGIP_DNS_MAXRECORDSCACHE 16
|
||||
#define SGIP_DNS_MAXRECORDADDRS 4
|
||||
#define SGIP_DNS_MAXALIASES 4
|
||||
#define SGIP_DNS_TIMEOUTMS 5000
|
||||
#define SGIP_DNS_MAXRETRY 3
|
||||
#define SGIP_DNS_MAXSERVERRETRY 4
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SGIP_DHCP_ERRORTIMEOUT 45000
|
||||
#define SGIP_DHCP_RESENDTIMEOUT 3000
|
||||
#define SGIP_DHCP_DEFAULTHOSTNAME "NintendoDS"
|
||||
#define SGIP_DHCP_CLASSNAME "sgIP 0.3"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Static memory settings - only used if SGIP_USEDYNAMICMEMORY is NOT defined.
|
||||
|
||||
// SGIP_TCP_MAXCONNECTIONS: In the case dynamic memory is not used, this value gives the max
|
||||
// number of TCP blocks available for inbound/outbound connections via TCP.
|
||||
#define SGIP_TCP_MAXCONNECTIONS 10
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Debugging options
|
||||
|
||||
|
||||
// SGIP_DEBUG: Enable debug logging.
|
||||
// requires external function "void sgIP_dbgprint(char *, ...);"
|
||||
//#define SGIP_DEBUG
|
||||
|
||||
#ifdef SGIP_DEBUG
|
||||
#define SGIP_DEBUG_MESSAGE(param) sgIP_dbgprint param
|
||||
#define SGIP_DEBUG_ERROR(param) sgIP_dbgprint param; while(1);
|
||||
#else
|
||||
#define SGIP_DEBUG_MESSAGE(param)
|
||||
#define SGIP_DEBUG_ERROR(param)
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Error handling
|
||||
extern int sgIP_errno;
|
||||
#define SGIP_ERROR(a) ((errno=(a)), -1)
|
||||
#define SGIP_ERROR0(a) ((errno=(a)), 0)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Error checking
|
||||
|
||||
|
||||
#ifdef SGIP_MULTITHREADED_THREADING_MODEL
|
||||
#ifdef SGIP_INTERRUPT_THREADING_MODEL
|
||||
#error SGIP_INTERRUPT_THREADING_MODEL and SGIP_MULTITHREADED_THREADING_MODEL cannot be used together!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// External option-based dependencies
|
||||
#include <nds/interrupts.h>
|
||||
|
||||
#ifdef SGIP_INTERRUPT_THREADING_MODEL
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void sgIP_IntrWaitEvent();
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#define SGIP_INTR_PROTECT() \
|
||||
int tIME; \
|
||||
tIME=enterCriticalSection()
|
||||
#define SGIP_INTR_REPROTECT() \
|
||||
tIME=enterCriticalSection()
|
||||
#define SGIP_INTR_UNPROTECT() \
|
||||
leaveCriticalSection(tIME)
|
||||
#define SGIP_WAITEVENT() \
|
||||
sgIP_IntrWaitEvent()
|
||||
#else // !SGIP_INTERRUPT_THREADING_MODEL
|
||||
#define SGIP_INTR_PROTECT()
|
||||
#define SGIP_INTR_REPROTECT()
|
||||
#define SGIP_INTR_UNPROTECT()
|
||||
#define SGIP_WAITEVENT();
|
||||
#endif // SGIP_INTERRUPT_THREADING_MODEL
|
||||
|
||||
#ifdef SGIP_DEBUG
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void sgIP_dbgprint(char *, ...);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif // SGIP_DEBUG
|
||||
|
||||
#ifdef SGIP_USEDYNAMICMEMORY
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void * sgIP_malloc(int);
|
||||
extern void sgIP_free(void *);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
#endif // SGIP_USEDYNAMICMEMORY
|
||||
|
||||
#endif
|
||||
86
third_party/dsiwifi/arm_host/source/nds/sgIP_DHCP.h
vendored
Normal file
86
third_party/dsiwifi/arm_host/source/nds/sgIP_DHCP.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_DHCP_H
|
||||
#define SGIP_DHCP_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_Hub.h"
|
||||
|
||||
// "DHCP Server" port is 67, "DHCP Client" port is 68
|
||||
// DHCP messages broadcast by a client prior to that client obtaining its IP address must have the source address field in the IP header set to 0.
|
||||
|
||||
|
||||
|
||||
typedef struct SGIP_DHCP_PACKET { // yes, freaking big endian prevails here too.
|
||||
unsigned char op; // opcode/message type (1=BOOTREQUEST, 2=BOOTREPLY)
|
||||
unsigned char htype; // hardware address type
|
||||
unsigned char hlen; // Hardware address length (should be 6, for ethernet/wifi)
|
||||
unsigned char hops; // set to 0
|
||||
unsigned long xid; // 4-byte client specified transaction ID
|
||||
unsigned short secs; // seconds elapsed since client started trying to boot
|
||||
unsigned short flags; // flags
|
||||
unsigned long ciaddr; // client IP address, filled in by client if verifying previous params
|
||||
unsigned long yiaddr; // "your" (client) IP address
|
||||
unsigned long siaddr; // IP addr of next server to use in bootstrap.
|
||||
unsigned long giaddr; // Relay agent IP address
|
||||
unsigned char chaddr[16]; // client hardware address
|
||||
char sname[64]; // optional server hostname (null terminated string)
|
||||
char file[128]; // boot file name, null terminated string
|
||||
char options[312]; // optional parameters
|
||||
} sgIP_DHCP_Packet;
|
||||
|
||||
enum SGIP_DHCP_STATUS {
|
||||
SGIP_DHCP_STATUS_IDLE,
|
||||
SGIP_DHCP_STATUS_WORKING,
|
||||
SGIP_DHCP_STATUS_FAILED,
|
||||
SGIP_DHCP_STATUS_SUCCESS
|
||||
};
|
||||
|
||||
#define DHCP_TYPE_DISCOVER 1
|
||||
#define DHCP_TYPE_OFFER 2
|
||||
#define DHCP_TYPE_REQUEST 3
|
||||
#define DHCP_TYPE_ACK 5
|
||||
#define DHCP_TYPE_RELEASE 7
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sgIP_DHCP_Init();
|
||||
|
||||
void sgIP_DHCP_SetHostName(char * s); // just for the fun of it.
|
||||
int sgIP_DHCP_IsDhcpIp(unsigned long ip); // check if the IP address was assigned via dhcp.
|
||||
void sgIP_DHCP_Start(sgIP_Hub_HWInterface * interface, int getDNS); // begin dhcp transaction to get IP and maybe DNS data.
|
||||
void sgIP_DHCP_Release(); // call to dump our DHCP address and leave.
|
||||
int sgIP_DHCP_Update(); // MUST be called periodicly after _Start; returns status - call until it returns something other than SGIP_DHCP_STATUS_WORKING
|
||||
void sgIP_DHCP_Terminate(); // kill the process where it stands; deallocate all DHCP resources.
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
69
third_party/dsiwifi/arm_host/source/nds/sgIP_DNS.h
vendored
Normal file
69
third_party/dsiwifi/arm_host/source/nds/sgIP_DNS.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_DNS_H
|
||||
#define SGIP_DNS_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
|
||||
#define SGIP_DNS_FLAG_ACTIVE 1
|
||||
#define SGIP_DNS_FLAG_RESOLVED 2
|
||||
#define SGIP_DNS_FLAG_BUSY 4
|
||||
|
||||
typedef struct SGIP_DNS_RECORD {
|
||||
char name [256];
|
||||
char aliases[SGIP_DNS_MAXALIASES][256];
|
||||
unsigned char addrdata[SGIP_DNS_MAXRECORDADDRS*4];
|
||||
short addrlen;
|
||||
short addrclass;
|
||||
int numaddr,numalias;
|
||||
int TTL;
|
||||
int flags;
|
||||
} sgIP_DNS_Record;
|
||||
|
||||
typedef struct SGIP_DNS_HOSTENT {
|
||||
char * h_name;
|
||||
char ** h_aliases;
|
||||
int h_addrtype; // class - 1=IN (internet)
|
||||
int h_length;
|
||||
char ** h_addr_list;
|
||||
} sgIP_DNS_Hostent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sgIP_DNS_Init();
|
||||
extern void sgIP_DNS_Timer1000ms();
|
||||
|
||||
extern sgIP_DNS_Hostent * sgIP_DNS_gethostbyname(const char * name);
|
||||
extern sgIP_DNS_Record * sgIP_DNS_GetUnusedRecord();
|
||||
extern sgIP_DNS_Record * sgIP_DNS_FindDNSRecord(const char * name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
109
third_party/dsiwifi/arm_host/source/nds/sgIP_Hub.h
vendored
Normal file
109
third_party/dsiwifi/arm_host/source/nds/sgIP_Hub.h
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_HUB_H
|
||||
#define SGIP_HUB_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_memblock.h"
|
||||
|
||||
|
||||
|
||||
#define SGIP_FLAG_PROTOCOL_IN_USE 0x0001
|
||||
#define SGIP_FLAG_PROTOCOL_ENABLED 0x8000
|
||||
|
||||
#define SGIP_FLAG_HWINTERFACE_IN_USE 0x0001
|
||||
#define SGIP_FLAG_HWINTERFACE_CONNECTED 0x0002
|
||||
#define SGIP_FLAG_HWINTERFACE_USEDHCP 0x0004
|
||||
#define SGIP_FLAG_HWINTERFACE_CHANGENETWORK 0x0008
|
||||
#define SGIP_FLAG_HWINTERFACE_ENABLED 0x8000
|
||||
|
||||
#ifdef SGIP_LITTLEENDIAN
|
||||
#define PROTOCOL_ETHER_ARP 0x0608
|
||||
#define PROTOCOL_ETHER_IP 0x0008
|
||||
#else
|
||||
#define PROTOCOL_ETHER_ARP 0x0806
|
||||
#define PROTOCOL_ETHER_IP 0x0800
|
||||
#endif
|
||||
|
||||
|
||||
// structure sgIP_Hub_Protocol: Used to record the interface between the sgIP Hub and a protocol handler
|
||||
typedef struct SGIP_HUB_PROTOCOL {
|
||||
unsigned short flags;
|
||||
unsigned short protocol;
|
||||
int (*ReceivePacket)(sgIP_memblock *);
|
||||
|
||||
} sgIP_Hub_Protocol;
|
||||
|
||||
typedef struct SGIP_HUB_HWINTERFACE {
|
||||
unsigned short flags;
|
||||
unsigned short hwaddrlen;
|
||||
int MTU;
|
||||
int (*TransmitFunction)(struct SGIP_HUB_HWINTERFACE *, sgIP_memblock *);
|
||||
void * userdata;
|
||||
unsigned long ipaddr, gateway, snmask, dns[3];
|
||||
unsigned char hwaddr[SGIP_MAXHWADDRLEN];
|
||||
} sgIP_Hub_HWInterface;
|
||||
|
||||
typedef struct SGIP_HEADER_ETHERNET {
|
||||
unsigned char dest_mac[6];
|
||||
unsigned char src_mac[6];
|
||||
unsigned short protocol;
|
||||
} sgIP_Header_Ethernet;
|
||||
|
||||
#define ntohs(num) htons(num)
|
||||
#define ntohl(num) htonl(num)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern void sgIP_Hub_Init();
|
||||
|
||||
|
||||
extern sgIP_Hub_Protocol * sgIP_Hub_AddProtocolInterface(int protocolID, int (*ReceivePacket)(sgIP_memblock *), int (*InterfaceInit)(sgIP_Hub_Protocol *));
|
||||
extern sgIP_Hub_HWInterface * sgIP_Hub_AddHardwareInterface(int (*TransmitFunction)(sgIP_Hub_HWInterface *, sgIP_memblock *), int (*InterfaceInit)(sgIP_Hub_HWInterface *));
|
||||
extern void sgIP_Hub_RemoveProtocolInterface(sgIP_Hub_Protocol * protocol);
|
||||
extern void sgIP_Hub_RemoveHardwareInterface(sgIP_Hub_HWInterface * hw);
|
||||
|
||||
extern int sgIP_Hub_ReceiveHardwarePacket(sgIP_Hub_HWInterface * hw, sgIP_memblock * packet);
|
||||
extern int sgIP_Hub_SendProtocolPacket(int protocol, sgIP_memblock * packet, unsigned long dest_address, unsigned long src_address);
|
||||
extern int sgIP_Hub_SendRawPacket(sgIP_Hub_HWInterface * hw, sgIP_memblock * packet);
|
||||
|
||||
extern int sgIP_Hub_IPMaxMessageSize(unsigned long ipaddr);
|
||||
unsigned long sgIP_Hub_GetCompatibleIP(unsigned long destIP);
|
||||
|
||||
extern sgIP_Hub_HWInterface * sgIP_Hub_GetDefaultInterface();
|
||||
|
||||
unsigned short htons(unsigned short num);
|
||||
unsigned long htonl(unsigned long num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
52
third_party/dsiwifi/arm_host/source/nds/sgIP_ICMP.h
vendored
Normal file
52
third_party/dsiwifi/arm_host/source/nds/sgIP_ICMP.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_ICMP_H
|
||||
#define SGIP_ICMP_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_memblock.h"
|
||||
|
||||
typedef struct SGIP_HEADER_ICMP {
|
||||
unsigned char type,code;
|
||||
unsigned short checksum;
|
||||
unsigned long xtra;
|
||||
} sgIP_Header_ICMP;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sgIP_ICMP_Init();
|
||||
|
||||
extern int sgIP_ICMP_ReceivePacket(sgIP_memblock * mb, unsigned long srcip, unsigned long destip);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
64
third_party/dsiwifi/arm_host/source/nds/sgIP_IP.h
vendored
Normal file
64
third_party/dsiwifi/arm_host/source/nds/sgIP_IP.h
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_IP_H
|
||||
#define SGIP_IP_H
|
||||
|
||||
#include "sgIP_memblock.h"
|
||||
|
||||
#define PROTOCOL_IP_ICMP 1
|
||||
#define PROTOCOL_IP_TCP 6
|
||||
#define PROTOCOL_IP_UDP 17
|
||||
|
||||
typedef struct SGIP_HEADER_IP {
|
||||
unsigned char version_ihl; // version = top 4 bits == 4, IHL = header length in 32bit increments = bottom 4 bits
|
||||
unsigned char type_of_service; // [3bit prescidence][ D ][ T ][ R ][ 0 0 ] - D=low delya, T=high thoroughput, R= high reliability
|
||||
unsigned short tot_length; // total length of packet including header
|
||||
unsigned short identification; // value assigned by sender to aid in packet reassembly
|
||||
unsigned short fragment_offset; // top 3 bits are flags [0][DF][MF] (Don't Fragment / More Fragments Exist) - offset is in 8-byte chunks.
|
||||
unsigned char TTL; // time to live, measured in hops
|
||||
unsigned char protocol; // protocols: ICMP=1, TCP=6, UDP=17
|
||||
unsigned short header_checksum; // checksum:
|
||||
unsigned long src_address; // src address is 32bit IP address
|
||||
unsigned long dest_address; // dest address is 32bit IP address
|
||||
unsigned char options[4]; // optional options come here.
|
||||
} sgIP_Header_IP;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int sgIP_IP_ReceivePacket(sgIP_memblock * mb);
|
||||
extern int sgIP_IP_MaxContentsSize(unsigned long destip);
|
||||
extern int sgIP_IP_RequiredHeaderSize();
|
||||
extern int sgIP_IP_SendViaIP(sgIP_memblock * mb, int protocol, unsigned long srcip, unsigned long destip);
|
||||
extern unsigned long sgIP_IP_GetLocalBindAddr(unsigned long srcip, unsigned long destip);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
134
third_party/dsiwifi/arm_host/source/nds/sgIP_TCP.h
vendored
Normal file
134
third_party/dsiwifi/arm_host/source/nds/sgIP_TCP.h
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
#ifndef SGIP_TCP_H
|
||||
#define SGIP_TCP_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_memblock.h"
|
||||
|
||||
enum SGIP_TCP_STATE {
|
||||
SGIP_TCP_STATE_NODATA, // newly allocated
|
||||
SGIP_TCP_STATE_UNUSED, // allocated & BINDed
|
||||
SGIP_TCP_STATE_LISTEN, // listening
|
||||
SGIP_TCP_STATE_SYN_SENT, // connect initiated
|
||||
SGIP_TCP_STATE_SYN_RECEIVED, // spawned from listen socket;
|
||||
SGIP_TCP_STATE_ESTABLISHED, // syns have been exchanged
|
||||
SGIP_TCP_STATE_FIN_WAIT_1, // sent a FIN, haven't got FIN or ACK yet.
|
||||
SGIP_TCP_STATE_FIN_WAIT_2, // got ACK for our FIN, haven't got FIN yet.
|
||||
SGIP_TCP_STATE_CLOSE_WAIT, // got FIN, wait for user code to close socket & send FIN
|
||||
SGIP_TCP_STATE_CLOSING, // got FIN, waiting for ACK of our FIN
|
||||
SGIP_TCP_STATE_LAST_ACK, // wait for ACK of our last FIN
|
||||
SGIP_TCP_STATE_TIME_WAIT, // wait to ensure remote tcp knows it's been terminated.
|
||||
SGIP_TCP_STATE_CLOSED, // Block is unused.
|
||||
};
|
||||
|
||||
|
||||
#define SGIP_TCP_FLAG_FIN 1
|
||||
#define SGIP_TCP_FLAG_SYN 2
|
||||
#define SGIP_TCP_FLAG_RST 4
|
||||
#define SGIP_TCP_FLAG_PSH 8
|
||||
#define SGIP_TCP_FLAG_ACK 16
|
||||
#define SGIP_TCP_FLAG_URG 32
|
||||
|
||||
typedef struct SGIP_HEADER_TCP {
|
||||
unsigned short srcport,destport;
|
||||
unsigned long seqnum;
|
||||
unsigned long acknum;
|
||||
unsigned char dataofs_;
|
||||
unsigned char tcpflags;
|
||||
unsigned short window;
|
||||
unsigned short checksum;
|
||||
unsigned short urg_ptr;
|
||||
unsigned char options[4];
|
||||
} sgIP_Header_TCP;
|
||||
|
||||
|
||||
// sgIP_Record_TCP - a TCP record, to store data for an active TCP connection.
|
||||
typedef struct SGIP_RECORD_TCP {
|
||||
struct SGIP_RECORD_TCP * next; // operate as a linked list
|
||||
// TCP state information
|
||||
int tcpstate;
|
||||
unsigned long sequence; // sequence number of first byte not acknowledged by remote system
|
||||
unsigned long ack; // external sequence number of next byte to receive
|
||||
unsigned long sequence_next; // sequence number of first unsent byte
|
||||
unsigned long rxwindow; // sequence of last byte in receive window
|
||||
unsigned long txwindow; // sequence of last byte allowed to send
|
||||
int time_last_action; // used for retransmission and etc.
|
||||
int time_backoff;
|
||||
int retrycount;
|
||||
unsigned long srcip;
|
||||
unsigned long destip;
|
||||
unsigned short srcport,destport;
|
||||
struct SGIP_RECORD_TCP ** listendata;
|
||||
int maxlisten;
|
||||
int errorcode;
|
||||
int want_shutdown; // 0= don't want shutdown, 1= want shutdown, 2= being shutdown
|
||||
int want_reack;
|
||||
// TCP buffer information:
|
||||
int buf_rx_in, buf_rx_out;
|
||||
int buf_tx_in, buf_tx_out;
|
||||
int buf_oob_in, buf_oob_out;
|
||||
unsigned char buf_rx[SGIP_TCP_RECEIVEBUFFERLENGTH];
|
||||
unsigned char buf_tx[SGIP_TCP_TRANSMITBUFFERLENGTH];
|
||||
unsigned char buf_oob[SGIP_TCP_OOBBUFFERLENGTH];
|
||||
} sgIP_Record_TCP;
|
||||
|
||||
typedef struct SGIP_TCP_SYNCOOKIE {
|
||||
unsigned long localseq, remoteseq;
|
||||
unsigned long localip, remoteip;
|
||||
unsigned short localport, remoteport;
|
||||
unsigned long timenext,timebackoff;
|
||||
sgIP_Record_TCP * linked; // parent listening connection
|
||||
} sgIP_TCP_SYNCookie;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sgIP_TCP_Init();
|
||||
extern void sgIP_TCP_Timer();
|
||||
|
||||
extern int sgIP_TCP_ReceivePacket(sgIP_memblock * mb, unsigned long srcip, unsigned long destip);
|
||||
extern int sgIP_TCP_SendPacket(sgIP_Record_TCP * rec, int flags, int datalength); // data sent is taken directly from the TX fifo.
|
||||
extern int sgIP_TCP_SendSynReply(int flags,unsigned long seq, unsigned long ack, unsigned long srcip, unsigned long destip, int srcport, int destport, int windowlen);
|
||||
|
||||
extern sgIP_Record_TCP * sgIP_TCP_AllocRecord();
|
||||
extern void sgIP_TCP_FreeRecord(sgIP_Record_TCP * rec);
|
||||
extern int sgIP_TCP_Bind(sgIP_Record_TCP * rec, int srcport, unsigned long srcip);
|
||||
extern int sgIP_TCP_Listen(sgIP_Record_TCP * rec, int maxlisten);
|
||||
extern sgIP_Record_TCP * sgIP_TCP_Accept(sgIP_Record_TCP * rec);
|
||||
extern int sgIP_TCP_Close(sgIP_Record_TCP * rec);
|
||||
extern int sgIP_TCP_Connect(sgIP_Record_TCP * rec, unsigned long destip, int destport);
|
||||
extern int sgIP_TCP_Send(sgIP_Record_TCP * rec, const char * datatosend, int datalength, int flags);
|
||||
extern int sgIP_TCP_Recv(sgIP_Record_TCP * rec, char * databuf, int buflength, int flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
81
third_party/dsiwifi/arm_host/source/nds/sgIP_UDP.h
vendored
Normal file
81
third_party/dsiwifi/arm_host/source/nds/sgIP_UDP.h
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef SGIP_UDP_H
|
||||
#define SGIP_UDP_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sgIP_memblock.h"
|
||||
|
||||
|
||||
enum SGIP_UDP_STATE {
|
||||
SGIP_UDP_STATE_UNBOUND, // newly allocated
|
||||
SGIP_UDP_STATE_BOUND, // got a source address/port
|
||||
SGIP_UDP_STATE_UNUSED, // no longer in use.
|
||||
};
|
||||
|
||||
|
||||
typedef struct SGIP_HEADER_UDP {
|
||||
unsigned short srcport,destport;
|
||||
unsigned short length,checksum;
|
||||
} sgIP_Header_UDP;
|
||||
|
||||
typedef struct SGIP_RECORD_UDP {
|
||||
struct SGIP_RECORD_UDP * next;
|
||||
|
||||
int state;
|
||||
unsigned long srcip;
|
||||
unsigned long destip;
|
||||
unsigned short srcport,destport;
|
||||
|
||||
sgIP_memblock * incoming_queue;
|
||||
sgIP_memblock * incoming_queue_end;
|
||||
|
||||
} sgIP_Record_UDP;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sgIP_UDP_Init();
|
||||
|
||||
int sgIP_UDP_CalcChecksum(sgIP_memblock * mb, unsigned long srcip, unsigned long destip, int totallength);
|
||||
int sgIP_UDP_ReceivePacket(sgIP_memblock * mb, unsigned long srcip, unsigned long destip);
|
||||
int sgIP_UDP_SendPacket(sgIP_Record_UDP * rec, const char * data, int datalen, unsigned long destip, int destport);
|
||||
|
||||
sgIP_Record_UDP * sgIP_UDP_AllocRecord();
|
||||
void sgIP_UDP_FreeRecord(sgIP_Record_UDP * rec);
|
||||
|
||||
int sgIP_UDP_Bind(sgIP_Record_UDP * rec, int srcport, unsigned long srcip);
|
||||
int sgIP_UDP_RecvFrom(sgIP_Record_UDP * rec, char * destbuf, int buflength, int flags, unsigned long * sender_ip, unsigned short * sender_port);
|
||||
int sgIP_UDP_SendTo(sgIP_Record_UDP * rec, const char * buf, int buflength, int flags, unsigned long dest_ip, int dest_port);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
65
third_party/dsiwifi/arm_host/source/nds/sgIP_memblock.h
vendored
Normal file
65
third_party/dsiwifi/arm_host/source/nds/sgIP_memblock.h
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef SGIP_MEMBLOCK_H
|
||||
#define SGIP_MEMBLOCK_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
|
||||
|
||||
typedef struct SGIP_MEMBLOCK {
|
||||
int totallength;
|
||||
int thislength;
|
||||
struct SGIP_MEMBLOCK * next;
|
||||
char * datastart;
|
||||
char reserved[SGIP_MEMBLOCK_DATASIZE-16]; // assume the other 4 values are 16 bytes total in length.
|
||||
} sgIP_memblock;
|
||||
|
||||
#define SGIP_MEMBLOCK_HEADERSIZE 16
|
||||
#define SGIP_MEMBLOCK_INTERNALSIZE (SGIP_MEMBLOCK_DATASIZE-16)
|
||||
#define SGIP_MEMBLOCK_FIRSTINTERNALSIZE (SGIP_MEMBLOCK_DATASIZE-16-SGIP_MAXHWHEADER)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sgIP_memblock_Init();
|
||||
extern sgIP_memblock * sgIP_memblock_alloc(int packetsize);
|
||||
extern sgIP_memblock * sgIP_memblock_allocHW(int headersize, int packetsize);
|
||||
extern void sgIP_memblock_free(sgIP_memblock * mb);
|
||||
extern void sgIP_memblock_exposeheader(sgIP_memblock * mb, int change);
|
||||
extern void sgIP_memblock_trimsize(sgIP_memblock * mb, int newsize);
|
||||
|
||||
extern int sgIP_memblock_IPChecksum(sgIP_memblock * mb, int startbyte, int chksum_length);
|
||||
extern int sgIP_memblock_CopyToLinear(sgIP_memblock * mb, void * dest_buf, int startbyte, int copy_length);
|
||||
extern int sgIP_memblock_CopyFromLinear(sgIP_memblock * mb, void * src_buf, int startbyte, int copy_length);
|
||||
extern int sgIP_memblock_CopyBlock(sgIP_memblock * mb_src, sgIP_memblock * mb_dest, int start_src, int start_dest, int copy_length);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
94
third_party/dsiwifi/arm_host/source/nds/sgIP_sockets.h
vendored
Normal file
94
third_party/dsiwifi/arm_host/source/nds/sgIP_sockets.h
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
// DSWifi Project - sgIP Internet Protocol Stack Implementation
|
||||
// Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org
|
||||
/******************************************************************************
|
||||
DSWifi Lib and test materials are licenced under the MIT open source licence:
|
||||
Copyright (c) 2005-2006 Stephen Stair
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef SGIP_SOCKETS_H
|
||||
#define SGIP_SOCKETS_H
|
||||
|
||||
#include "sgIP_Config.h"
|
||||
#include "sys/socket.h"
|
||||
#include "netinet/in.h"
|
||||
#include "netdb.h"
|
||||
|
||||
#define SGIP_SOCKET_FLAG_ALLOCATED 0x8000
|
||||
#define SGIP_SOCKET_FLAG_NONBLOCKING 0x4000
|
||||
#define SGIP_SOCKET_FLAG_VALID 0x2000
|
||||
#define SGIP_SOCKET_FLAG_CLOSING 0x1000
|
||||
#define SGIP_SOCKET_FLAG_TYPEMASK 0x0001
|
||||
#define SGIP_SOCKET_FLAG_TYPE_TCP 0x0001
|
||||
#define SGIP_SOCKET_FLAG_TYPE_UDP 0x0000
|
||||
#define SGIP_SOCKET_MASK_CLOSE_COUNT 0xFFFF0000
|
||||
#define SGIP_SOCKET_SHIFT_CLOSE_COUNT 16
|
||||
|
||||
// Maybe define a better value for this in the future. But 5 minutes sounds ok.
|
||||
// TCP specification disagrees on this point, but this is a limited platform.
|
||||
// 5 minutes assuming 1000ms ticks = 300 = 0x12c
|
||||
#define SGIP_SOCKET_VALUE_CLOSE_COUNT (0x12c << SGIP_SOCKET_SHIFT_CLOSE_COUNT)
|
||||
|
||||
typedef struct SGIP_SOCKET_DATA {
|
||||
unsigned int flags;
|
||||
void * conn_ptr;
|
||||
} sgIP_socket_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void sgIP_sockets_Init();
|
||||
extern void sgIP_sockets_Timer1000ms();
|
||||
|
||||
// sys/socket.h
|
||||
extern int socket(int domain, int type, int protocol);
|
||||
extern int bind(int socket, const struct sockaddr * addr, int addr_len);
|
||||
extern int connect(int socket, const struct sockaddr * addr, int addr_len);
|
||||
extern int send(int socket, const void * data, int sendlength, int flags);
|
||||
extern int recv(int socket, void * data, int recvlength, int flags);
|
||||
extern int sendto(int socket, const void * data, int sendlength, int flags, const struct sockaddr * addr, int addr_len);
|
||||
extern int recvfrom(int socket, void * data, int recvlength, int flags, struct sockaddr * addr, int * addr_len);
|
||||
extern int listen(int socket, int max_connections);
|
||||
extern int accept(int socket, struct sockaddr * addr, int * addr_len);
|
||||
extern int shutdown(int socket, int shutdown_type);
|
||||
extern int closesocket(int socket);
|
||||
extern int forceclosesocket(int socket);
|
||||
|
||||
extern int ioctl(int socket, long cmd, void * arg);
|
||||
|
||||
extern int setsockopt(int socket, int level, int option_name, const void * data, int data_len);
|
||||
extern int getsockopt(int socket, int level, int option_name, void * data, int * data_len);
|
||||
|
||||
extern int getpeername(int socket, struct sockaddr *addr, int * addr_len);
|
||||
extern int getsockname(int socket, struct sockaddr *addr, int * addr_len);
|
||||
|
||||
// sys/time.h (actually intersects partly with libnds, so I'm letting libnds handle fd_set for the time being)
|
||||
extern int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
|
||||
|
||||
// arpa/inet.h
|
||||
extern unsigned long inet_addr(const char *cp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user