1 /* Include Unity header */
2 #include <unity.h>
3
4 /* Include standard libraries */
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdint.h>
8 #include "FreeRTOS.h"
9 #include "task.h"
10 #include "list.h"
11
12 #include "FreeRTOS_IP.h"
13 #include "FreeRTOS_IP_Private.h"
14
15 volatile BaseType_t xInsideInterrupt = pdFALSE;
16
17 /** @brief The expected IP version and header length coded into the IP header itself. */
18 #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 )
19
20 UDPPacketHeader_t xDefaultPartUDPPacketHeader =
21 {
22 /* .ucBytes : */
23 {
24 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */
25 0x08, 0x00, /* Ethernet frame type. */
26 ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */
27 0x00, /* ucDifferentiatedServicesCode. */
28 0x00, 0x00, /* usLength. */
29 0x00, 0x00, /* usIdentification. */
30 0x00, 0x00, /* usFragmentOffset. */
31 ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */
32 ipPROTOCOL_UDP, /* ucProtocol. */
33 0x00, 0x00, /* usHeaderChecksum. */
34 0x00, 0x00, 0x00, 0x00 /* Source IP address. */
35 }
36 };
37
38
39 /*
40 * IP-clash detection is currently only used internally. When DHCP doesn't respond, the
41 * driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a
42 * gratuitous ARP message and, after a period of time, check the variables here below:
43 */
44 #if ( ipconfigARP_USE_CLASH_DETECTION != 0 )
45 /* Becomes non-zero if another device responded to a gratuitous ARP message. */
46 BaseType_t xARPHadIPClash;
47 /* MAC-address of the other device containing the same IP-address. */
48 MACAddress_t xARPClashMacAddress;
49 #endif /* ipconfigARP_USE_CLASH_DETECTION */
50
51
52 /** @brief For convenience, a MAC address of all 0xffs is defined const for quick
53 * reference. */
54 const MACAddress_t xBroadcastMACAddress = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
55
56 /** @brief Structure that stores the netmask, gateway address and DNS server addresses. */
57 NetworkAddressingParameters_t xNetworkAddressing =
58 {
59 0xC0C0C0C0, /* 192.192.192.192 - Default IP address. */
60 0xFFFFFF00, /* 255.255.255.0 - Netmask. */
61 0xC0C0C001, /* 192.192.192.1 - Gateway Address. */
62 0x01020304, /* 1.2.3.4 - DNS server address. */
63 0xC0C0C0FF
64 }; /* 192.192.192.255 - Broadcast address. */
65
66 /** @brief Structure that stores the netmask, gateway address and DNS server addresses. */
67 NetworkAddressingParameters_t xDefaultAddressing =
68 {
69 0xC0C0C0C0, /* 192.192.192.192 - Default IP address. */
70 0xFFFFFF00, /* 255.255.255.0 - Netmask. */
71 0xC0C0C001, /* 192.192.192.1 - Gateway Address. */
72 0x01020304, /* 1.2.3.4 - DNS server address. */
73 0xC0C0C0FF
74 };
75
xPortGetMinimumEverFreeHeapSize(void)76 size_t xPortGetMinimumEverFreeHeapSize( void )
77 {
78 return 0;
79 }
80
xApplicationDNSQueryHook(const char * pcName)81 BaseType_t xApplicationDNSQueryHook( const char * pcName )
82 {
83 return 0;
84 }
85
pxPortInitialiseStack(StackType_t * pxTopOfStack,StackType_t * pxEndOfStack,TaskFunction_t pxCode,void * pvParameters)86 StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
87 StackType_t * pxEndOfStack,
88 TaskFunction_t pxCode,
89 void * pvParameters )
90 {
91 return 0;
92 }
93
ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,uint16_t usSourcePort,uint32_t ulDestinationAddress,uint16_t usDestinationPort)94 uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
95 uint16_t usSourcePort,
96 uint32_t ulDestinationAddress,
97 uint16_t usDestinationPort )
98 {
99 return 0;
100 }
101
xNetworkInterfaceInitialise(void)102 BaseType_t xNetworkInterfaceInitialise( void )
103 {
104 return 0;
105 }
106
vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent)107 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
108 {
109 }
110
vApplicationDaemonTaskStartupHook(void)111 void vApplicationDaemonTaskStartupHook( void )
112 {
113 }
114
vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer,StackType_t ** ppxTimerTaskStackBuffer,uint32_t * pulTimerTaskStackSize)115 void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
116 StackType_t ** ppxTimerTaskStackBuffer,
117 uint32_t * pulTimerTaskStackSize )
118 {
119 }
120
vPortDeleteThread(void * pvTaskToDelete)121 void vPortDeleteThread( void * pvTaskToDelete )
122 {
123 }
124
vApplicationIdleHook(void)125 void vApplicationIdleHook( void )
126 {
127 }
128
vApplicationTickHook(void)129 void vApplicationTickHook( void )
130 {
131 }
132
ulGetRunTimeCounterValue(void)133 unsigned long ulGetRunTimeCounterValue( void )
134 {
135 return 0;
136 }
137
vPortEndScheduler(void)138 void vPortEndScheduler( void )
139 {
140 }
141
xPortStartScheduler(void)142 BaseType_t xPortStartScheduler( void )
143 {
144 return 0;
145 }
146
vPortEnterCritical(void)147 void vPortEnterCritical( void )
148 {
149 }
150
vPortExitCritical(void)151 void vPortExitCritical( void )
152 {
153 }
154
vPortGenerateSimulatedInterrupt(uint32_t ulInterruptNumber)155 void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber )
156 {
157 }
158
vPortCloseRunningThread(void * pvTaskToDelete,volatile BaseType_t * pxPendYield)159 void vPortCloseRunningThread( void * pvTaskToDelete,
160 volatile BaseType_t * pxPendYield )
161 {
162 }
163
vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer,StackType_t ** ppxIdleTaskStackBuffer,uint32_t * pulIdleTaskStackSize)164 void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
165 StackType_t ** ppxIdleTaskStackBuffer,
166 uint32_t * pulIdleTaskStackSize )
167 {
168 }
169
vConfigureTimerForRunTimeStats(void)170 void vConfigureTimerForRunTimeStats( void )
171 {
172 }
173
xNetworkInterfaceOutput(NetworkBufferDescriptor_t * const pxNetworkBuffer,BaseType_t bReleaseAfterSend)174 BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer,
175 BaseType_t bReleaseAfterSend )
176 {
177 return pdPASS;
178 }
179 /*-----------------------------------------------------------*/
180