1 /*******************************************************************************
\r
2 * (c) Copyright 2009 SLS Corporation,All Rights Reserved.
\r
4 * tcpip.h:header file of TCP/IP implementation.
\r
6 * Version Author Comment
\r
7 * 1.0.0 SLS corp. First release,16 Jan 2009
\r
12 #define FLASH_CONTEXT_INDICATOR 0x20000000
\r
13 #define FLASH_SELFWAKEUP_INDICATOR 0x20000001
\r
14 #define FLASH_CONTEXT_LOCATION 0x20000002
\r
16 /***************************************************************************//**
\r
17 * Replies to ARP requests.
\r
19 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
22 unsigned char send_arp_reply(unsigned char *buf);
\r
23 /***************************************************************************//**
\r
24 * Sends gratuitous arp brodcast message to the LAN.
\r
26 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
29 void send_gratuitous_arp(unsigned char *buf);
\r
30 /***************************************************************************//**
\r
31 * Calculates the checksum for Ethernet data in the header.
\r
33 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
34 * @param len Number of bytes.
\r
35 * @param pos position for the check sum.
\r
37 * @return value of the checksum
\r
39 unsigned short int get_checksum(unsigned char *buf, unsigned short int len, unsigned short int pos);
\r
40 /***************************************************************************//**
\r
41 * Calls internally to get_checksum and fixes the value of the checksum to
\r
44 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
45 * @param len Number of bytes.
\r
46 * @param pos position for the check sum.
\r
50 unsigned char fix_checksum(unsigned char *buf, unsigned short int len, unsigned short int pos);
\r
51 /***************************************************************************//**
\r
52 * Checks the calculated checksum for the errors.
\r
54 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
55 * @param len Number of bytes.
\r
56 * @param pos position for the check sum.
\r
58 * @return OK If there is no error
\r
59 * ERR If there is error in the data
\r
61 unsigned char check_checksum(unsigned char *buf, unsigned short int len, unsigned short int pos, char type);
\r
62 /***************************************************************************//**
\r
63 * Sends the reply to ICMP request like PING.
\r
65 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
67 unsigned char send_icmp_echo_reply(unsigned char *buf);
\r
68 /***************************************************************************//**
\r
69 * Converts the input integer to the ascii char and fills in the buffer.
\r
71 * @param buf To filled in by the ascii value.
\r
72 * @param n integer number
\r
74 void dtoa_reverse(unsigned short int n, unsigned char *buf);
\r
75 /***************************************************************************//**
\r
76 * Sends DHCP request to the server available in LAN.
\r
78 * @param buf Pointer to the recieved data in case of DHCP reply.Zero for request.
\r
80 void send_bootp_packet (unsigned char *buf);
\r
81 /***************************************************************************//**
\r
82 * Processes the UDP datagram.
\r
84 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
86 unsigned char process_udp_packet (unsigned char *buf);
\r
87 /***************************************************************************//**
\r
88 * Sends TCP packet to the network.
\r
90 * @param buf Pointer to the transmitt buffer to Ethernet MAC.
\r
92 void send_tcp_packet (unsigned char control_bits,unsigned short int buflen);
\r
93 /***************************************************************************//**
\r
94 * Initialize TCP for the software TCP/IP stack.
\r
98 unsigned char tcp_init(void);
\r
99 /***************************************************************************//**
\r
100 * Converts two hex decimal ascii digits into a sigle integer digit.
\r
102 * @param u ascii hex digit
\r
103 * l ascii hex digit
\r
104 * @returm converted integer byte
\r
107 unsigned char hex_digits_to_byte(unsigned char u, unsigned char l);
\r
108 /***************************************************************************//**
\r
109 * Processes ICMP packets
\r
111 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
113 * @return ERR if there is an error in the data
\r
114 * or calls further necessary functions.
\r
116 unsigned char process_icmp_packet(unsigned char *buf);
\r
117 /***************************************************************************//**
\r
118 * Sends logo of ACTEL on the network over HTTP protocol.
\r
121 unsigned char http_send_logo ();
\r
122 /***************************************************************************//**
\r
123 * Sends appropriate answer to the different HTTP requests.
\r
125 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
128 unsigned char send_http_response(unsigned char *buf);
\r
129 /***************************************************************************//**
\r
130 * Process incoming TCP requests and handles the TCP state machine.
\r
132 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
135 unsigned char process_tcp_packet(unsigned char *buf);
\r
136 /***************************************************************************//**
\r
137 * Process incoming IP datagrams and handles the TCP state machine.
\r
139 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
142 unsigned char process_ip_packet(unsigned char *buf);
\r
143 /***************************************************************************//**
\r
144 * Processes the ARP packets.
\r
145 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
148 unsigned char process_arp_packet(unsigned char *buf);
\r
149 /***************************************************************************//**
\r
150 * Processes incoming packets and identifies its type.
\r
152 * @param buf Pointer to the recieved buffer from Ethernet MAC.
\r
153 * @return call the function for further process
\r
156 unsigned char process_packet( unsigned char * buf );
\r
157 /***************************************************************************//**
\r
158 * copies source string to destination address.
\r
160 * @param d Pointer to the destination
\r
161 * @param s Pointer to the source
\r
162 * @return The last location after copy
\r
165 unsigned char *xstrcpy(unsigned char *d, const unsigned char *s);
\r
166 /***************************************************************************//**
\r
167 * Sends the home page of the demonstration webserver.
\r
170 void http_send_packet();
\r
171 /***************************************************************************//**
\r
172 * Sends the packet for waveform mode.
\r
175 void http_send_packet_waveform();
\r
176 /***************************************************************************//**
\r
177 * Sends the packet for multimeter mode.
\r
180 void http_send_packet_multimeter();
\r
181 /***************************************************************************//**
\r
182 * Sends the packet for DAC mode.
\r
185 void http_send_packet_DAC();
\r
186 /***************************************************************************//**
\r
187 * Sends the packet for sleeping stopwatch.
\r
190 void http_send_packet_SLEEPING_STOPWATCH();
\r
191 /***************************************************************************//**
\r
192 * Sends the packet for text terminal.
\r
195 void http_send_packet_textterminal();
\r
196 /***************************************************************************//**
\r
197 * Sends the packet for VIT auxiliary mode.
\r
200 void http_send_packet_VIT();
\r
201 /***************************************************************************//**
\r
202 * Sends the packet for Real Time Data Display.
\r
205 void http_send_packet_RTDD();
\r
206 /***************************************************************************//**
\r
207 * Sends the packet for Stock Ticker.
\r
210 void http_send_packet_Stockticker();
\r
211 /***************************************************************************//**
\r
212 * Sends the packet for Gadgets mode.
\r
215 void http_send_packet_weatherblog();
\r
216 /***************************************************************************//**
\r
217 * Sends the packet for Selfwakeup.
\r
220 void http_send_packet_SELFWAKEUP();
\r
221 /***************************************************************************//**
\r
222 * Same as above mentioned functions but following functions are applicable
\r
223 * to Internet Explorer.
\r
226 void http_send_packet_IE();
\r
227 void http_send_packet_SELFWAKEUP_IE();
\r
228 void http_send_packet_VIT_IE();
\r
229 void http_send_packet_waveform_IE();
\r
230 void http_send_packet_SLEEPING_STOPWATCH_IE();
\r
231 void http_send_packet_DAC_IE();
\r
232 void http_send_packet_multimeter_IE();
\r
233 void http_send_packet_RTDD_IE();
\r
234 #endif /*TCPIP_H_*/
\r