Aktuální adresář: FITkit /
trunk /
mcu /
libs /
enc28j60 /
enc28j60_ip.h
1 /*******************************************************************************
2 enc28j60_ip.h: Sitova vrstva modelu TCP/IP
3 Copyright (C) 2010 Brno University of Technology,
4 Faculty of Information Technology
5 Author(s): Martin Musil <xmusil34 AT fit.vutbr.cz>
6
7 LICENSE TERMS
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12 1. Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in
16 the documentation and/or other materials provided with the
17 distribution.
18 3. All advertising materials mentioning features or use of this software
19 or firmware must display the following acknowledgement:
20
21 This product includes software developed by the University of
22 Technology, Faculty of Information Technology, Brno and its
23 contributors.
24
25 4. Neither the name of the Company nor the names of its contributors
26 may be used to endorse or promote products derived from this
27 software without specific prior written permission.
28
29 This software or firmware is provided ``as is'', and any express or implied
30 warranties, including, but not limited to, the implied warranties of
31 merchantability and fitness for a particular purpose are disclaimed.
32 In no event shall the company or contributors be liable for any
33 direct, indirect, incidental, special, exemplary, or consequential
34 damages (including, but not limited to, procurement of substitute
35 goods or services; loss of use, data, or profits; or business
36 interruption) however caused and on any theory of liability, whether
37 in contract, strict liability, or tort (including negligence or
38 otherwise) arising in any way out of the use of this software, even
39 if advised of the possibility of such damage.
40
41 $Id$
42
43 *******************************************************************************/
44
45 /**
46 \file enc28j60_ip.h
47
48 */
49
50 #ifndef _ENC28J60_IP_
51 #define _ENC28J60_IP_
52
53
54 //****************************
55 //prevody
56 //****************************
57
58 #define HTONS(x) ((((x)&0xff)<<8) | ((x)>>8))
59
60 #define HTONL(x) ((((x)&0xff)<<24) | (((x)&0x00ff0000l)>>8) | (((x)&0x0000ff00l)<<8) | ((x)>>24))
61
62
63
64
65 /**
66
67 **/
68 #define CHAR2IP(x0,x1,x2,x3) ( ((unsigned long)x0<<24)|((unsigned long)x1<<16)|((unsigned int)x2<<8)|x3)
69
70 /**
71 \cond
72 **/
73
74
75
76
77
78
79
80 #define IP_FRAG_OFFSET 0x1fff
81 #define IP_FRAG_MORE 0x2000
82 #define IP_FRAG_DONT 0x4000
83 #define IP_FRAG_RESERVED 0x8000
84
85
86
87
88
89
90
91
92
93
94 /**
95 \endcond
96 **/
97
98 /**
99
100
101 \struct ip_h
102 **/
103 struct ip_h{
104
105 unsigned char ipv:4; ///< verze IP protokolu
106
107
108 unsigned int identification; ///< identifikace paketu
109 unsigned int fragment; ///< offset fragmentu a flagy
110 unsigned char ttl; ///< Time to Live
111
112
113
114
115 };
116
117 /**
118 \cond
119 **/
120
121 /******************/
122
123 /**
124
125 **/
126 void ip_recv(void);
127
128 /**
129
130
131
132
133
134
135 **/
136 char ip_send(unsigned long dest_addr,unsigned char protocol);
137
138 /**
139
140 \param pointer - ukazatel na blok dat
141
142 \returns checksum
143 **/
144 unsigned int count_checksum(void* pointer,int count);
145
146 /**
147 \endcond
148 **/
149 /******************/
150
151 /**
152
153
154 \see set_ip_l()
155 **/
156 inline void set_ip(unsigned char a0,unsigned char a1,unsigned char a2, unsigned char a3);
157
158 /**
159
160
161 \see set_ip()
162 **/
163 inline void set_ip_l(unsigned long ip);
164
165 /**
166
167
168 **/
169 inline unsigned long get_ip();
170
171
172 /******************/
173
174 /**
175
176
177 \see set_netmask_l()
178 **/
179 inline void set_netmask(unsigned char m0,unsigned char m1,unsigned char m2, unsigned char m3);
180
181 /**
182
183
184 \see set_netmask()
185 **/
186 inline void set_netmask_l(unsigned long netmask);
187
188 /**
189
190
191 **/
192 inline unsigned long get_netmask();
193
194
195
196 /******************/
197
198
199 /**
200
201
202 \see set_gateway_l()
203 **/
204 inline void set_gateway(unsigned char g0,unsigned char g1,unsigned char g2, unsigned char g3);
205
206 /**
207
208
209 \see set_gateway()
210 **/
211 inline void set_gateway_l(unsigned long gateway);
212
213 /**
214
215
216 **/
217 inline unsigned long get_gateway();
218
219
220 /******************/
221
222 /**
223
224
225 \see set_dns_server_l()
226 **/
227 inline void set_dns_server(unsigned char d0,unsigned char d1,unsigned char d2, unsigned char d3);
228
229 /**
230
231
232 \see set_dns_server()
233 **/
234 inline void set_dns_server_l(unsigned long dns);
235
236 /**
237
238
239 **/
240 inline unsigned long get_dns_server();
241
242
243
244 #endif /*_ENC28J60_IP_*/
245