Compare commits
1555 Commits
start
...
STABLE-1_3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6111230fe9 | ||
|
|
6bce84e070 | ||
|
|
a6e316a92d | ||
|
|
22bcf5892a | ||
|
|
cc4b968f0a | ||
|
|
893ddcf61b | ||
|
|
cf81dbcca4 | ||
|
|
5830200029 | ||
|
|
972592cf8a | ||
|
|
ce5699f41b | ||
|
|
1eee0be951 | ||
|
|
fb555a0633 | ||
|
|
2b87f899ab | ||
|
|
776e1926a3 | ||
|
|
c232edb83a | ||
|
|
aefeba3fc0 | ||
|
|
6d4064799a | ||
|
|
e0e9a63e63 | ||
|
|
bcdffce6ce | ||
|
|
ff97c8a1a9 | ||
|
|
30acd1662d | ||
|
|
078e2f60d6 | ||
|
|
c7ce2792c8 | ||
|
|
22d6558f13 | ||
|
|
105d72a3c2 | ||
|
|
c752e5731c | ||
|
|
72e9cf53e7 | ||
|
|
e66d315c9b | ||
|
|
95f6dc7011 | ||
|
|
ac9e758f41 | ||
|
|
518b18dad0 | ||
|
|
bdd5586cee | ||
|
|
14dba4ae2b | ||
|
|
99d82c4980 | ||
|
|
fb46e0f192 | ||
|
|
b055128ec4 | ||
|
|
e29f94a980 | ||
|
|
24342eaab0 | ||
|
|
152d22d4f9 | ||
|
|
41eecb67d2 | ||
|
|
9317105c37 | ||
|
|
23d7f5425d | ||
|
|
217f279fdb | ||
|
|
d4ecb23015 | ||
|
|
42c59e1079 | ||
|
|
3b5993e6ee | ||
|
|
4b8255a588 | ||
|
|
36e3d24331 | ||
|
|
261dfdf010 | ||
|
|
cbfacb7ed9 | ||
|
|
4eda29abf9 | ||
|
|
c3f7107e2b | ||
|
|
67a3976a24 | ||
|
|
4fba1b1430 | ||
|
|
029b786c77 | ||
|
|
51e02176da | ||
|
|
ed65d9cd75 | ||
|
|
542b8fffb1 | ||
|
|
12c50ed87b | ||
|
|
9d5bf57dd9 | ||
|
|
04df18bcd3 | ||
|
|
422ba5bcec | ||
|
|
27b28a9306 | ||
|
|
620b3e6739 | ||
|
|
580f334274 | ||
|
|
4f52183a39 | ||
|
|
a55f354687 | ||
|
|
9630c9136b | ||
|
|
dbd6d7ec8d | ||
|
|
b3a5d6df0d | ||
|
|
3587e8481d | ||
|
|
4f8f6ba205 | ||
|
|
f81ed216db | ||
|
|
f1a9f7ea70 | ||
|
|
4b14621208 | ||
|
|
baf30f5eae | ||
|
|
e7a2ab5de9 | ||
|
|
fd41c5de2d | ||
|
|
efac109803 | ||
|
|
84505d4cc8 | ||
|
|
7d8fac62ec | ||
|
|
b6e18d9c6f | ||
|
|
c05e968278 | ||
|
|
103fe60362 | ||
|
|
638020ec70 | ||
|
|
56038b6457 | ||
|
|
96b788bea7 | ||
|
|
7b6c11360f | ||
|
|
ea1eb45e3f | ||
|
|
e001a021d5 | ||
|
|
14cb4eb735 | ||
|
|
d976c8e85f | ||
|
|
d2d33cb984 | ||
|
|
eeae59ecb7 | ||
|
|
466f4e699c | ||
|
|
bf09400c4c | ||
|
|
c4509e700d | ||
|
|
6472e3b35e | ||
|
|
f9bd5019fa | ||
|
|
8c7705bbf9 | ||
|
|
243e3d0d91 | ||
|
|
19884f40b8 | ||
|
|
10c3ce08af | ||
|
|
878532a30d | ||
|
|
102d69004a | ||
|
|
b0c61ffbb1 | ||
|
|
9f96f09652 | ||
|
|
aa568727d1 | ||
|
|
411cb39eb4 | ||
|
|
6777ae2ada | ||
|
|
2cf3e6e9bc | ||
|
|
491b73d5f2 | ||
|
|
1f3fe200df | ||
|
|
299e2a7077 | ||
|
|
13a139eef7 | ||
|
|
06df1647e1 | ||
|
|
1d2804d6a2 | ||
|
|
ba98bcdc60 | ||
|
|
0d7dccba5e | ||
|
|
c231e95cce | ||
|
|
6f6c8c5434 | ||
|
|
edf72a7dfb | ||
|
|
ba636e19a2 | ||
|
|
6374766a55 | ||
|
|
c779a9f29f | ||
|
|
ae2d5266c5 | ||
|
|
99db244124 | ||
|
|
8367feafa9 | ||
|
|
f6a28808e3 | ||
|
|
13d8ae859d | ||
|
|
95b15fe463 | ||
|
|
779938ea68 | ||
|
|
139944a3ac | ||
|
|
b94e3a874d | ||
|
|
3d8e5003af | ||
|
|
94cd14e90d | ||
|
|
c93cfb2c74 | ||
|
|
521d439a07 | ||
|
|
460b18e82c | ||
|
|
ef3666ef26 | ||
|
|
e0aaa87b1f | ||
|
|
eba83ab740 | ||
|
|
a8141c53a8 | ||
|
|
88ff8c83e9 | ||
|
|
24e0b25215 | ||
|
|
7bc881ccc5 | ||
|
|
a3bc6cd666 | ||
|
|
40d4a8fc2f | ||
|
|
7be9e292dc | ||
|
|
9ccd31a12e | ||
|
|
a9aefcc1be | ||
|
|
05587f5da9 | ||
|
|
43dd38df0a | ||
|
|
64fa8d78bc | ||
|
|
aee9c4c8e6 | ||
|
|
bcb4afa886 | ||
|
|
7774b57a1c | ||
|
|
90cb4b4e09 | ||
|
|
7fa9010f35 | ||
|
|
03f888c968 | ||
|
|
e07d71f5e8 | ||
|
|
afcf49ad3a | ||
|
|
a2f1892480 | ||
|
|
552106e2a4 | ||
|
|
a48370d5e9 | ||
|
|
f067d34392 | ||
|
|
30d4c243ec | ||
|
|
2637f2ad3a | ||
|
|
9b92f4c882 | ||
|
|
42344ce20c | ||
|
|
faca23b984 | ||
|
|
0cbd7501a1 | ||
|
|
03aa8270a6 | ||
|
|
ef70313e05 | ||
|
|
2ec3c46838 | ||
|
|
52e8ec03ba | ||
|
|
c54777d957 | ||
|
|
7b11fb75d9 | ||
|
|
e937521014 | ||
|
|
f02c39a402 | ||
|
|
c580c2be75 | ||
|
|
8d0f689cb5 | ||
|
|
bfd96264e6 | ||
|
|
baab7c04f7 | ||
|
|
3572ec784d | ||
|
|
6f00cbb6ef | ||
|
|
7518acf634 | ||
|
|
52e6922e5a | ||
|
|
82ddf82866 | ||
|
|
55bcc20deb | ||
|
|
9906e4c984 | ||
|
|
886cfbe12d | ||
|
|
4e40fee1db | ||
|
|
bceff76c70 | ||
|
|
b333b7c9dc | ||
|
|
de4b9b584c | ||
|
|
bf924118de | ||
|
|
a41f113b8f | ||
|
|
5941b3c86e | ||
|
|
caa1834b70 | ||
|
|
c61262d839 | ||
|
|
9c4daa312d | ||
|
|
32005617b9 | ||
|
|
1dfa246674 | ||
|
|
7e616ea71c | ||
|
|
99afb15ced | ||
|
|
22e2540eb6 | ||
|
|
8d39b1a152 | ||
|
|
1ed34774c8 | ||
|
|
48e62e25e9 | ||
|
|
1cb470662b | ||
|
|
add4874801 | ||
|
|
8cc32bc29c | ||
|
|
fc2d28b851 | ||
|
|
a3ef33c56f | ||
|
|
ba4254231e | ||
|
|
2b54da5070 | ||
|
|
d2fa5c91a7 | ||
|
|
4653974c2a | ||
|
|
de11e7fd75 | ||
|
|
1dd1064051 | ||
|
|
ac10470643 | ||
|
|
8d3d08e814 | ||
|
|
3f96a15fd4 | ||
|
|
22f51f953b | ||
|
|
f3f7bd00e5 | ||
|
|
a72e4a406f | ||
|
|
2fe1254aae | ||
|
|
e4590b26fb | ||
|
|
325d6e7cfa | ||
|
|
6bce832060 | ||
|
|
37a5a87057 | ||
|
|
865f6eb5f3 | ||
|
|
dde6ddfd7c | ||
|
|
47d8d69b81 | ||
|
|
df1b7ea311 | ||
|
|
113a52d091 | ||
|
|
081e4d9209 | ||
|
|
e5a98b6a5b | ||
|
|
2942157ca4 | ||
|
|
6746beb2a3 | ||
|
|
92aa004b75 | ||
|
|
b28cd02149 | ||
|
|
cedd5c21e6 | ||
|
|
b714cd5f4b | ||
|
|
788892ee7c | ||
|
|
1b07fecbf3 | ||
|
|
4a01122fb7 | ||
|
|
4211da00b3 | ||
|
|
7f3cff6e09 | ||
|
|
6e612e5def | ||
|
|
a7718b2ef3 | ||
|
|
472407c719 | ||
|
|
f07c1cf874 | ||
|
|
ce7c311ecf | ||
|
|
499c63bd0a | ||
|
|
03777ccb21 | ||
|
|
b4741332e0 | ||
|
|
3874f5f5e8 | ||
|
|
8c19f9a57e | ||
|
|
f57c2424cf | ||
|
|
181b68b01e | ||
|
|
93d5bed697 | ||
|
|
5743b11925 | ||
|
|
4dcfdac2f5 | ||
|
|
9343b767f8 | ||
|
|
77d9233427 | ||
|
|
f63a3c1f62 | ||
|
|
511cdfb951 | ||
|
|
e1f49d990b | ||
|
|
1b208d0954 | ||
|
|
4ac4d56b53 | ||
|
|
c7a0f32c98 | ||
|
|
be0686d905 | ||
|
|
9940b049ec | ||
|
|
3d9c76a69c | ||
|
|
7797ada1f5 | ||
|
|
3fc883e8fb | ||
|
|
8cfd923aaa | ||
|
|
c86b446d4c | ||
|
|
32a09370e1 | ||
|
|
32c6893081 | ||
|
|
95425552d7 | ||
|
|
dc515c7ad3 | ||
|
|
c31b405af6 | ||
|
|
e7483f2e64 | ||
|
|
9a524dac86 | ||
|
|
b3c52f574a | ||
|
|
f58515b51e | ||
|
|
da4df1f414 | ||
|
|
7f0640b040 | ||
|
|
8c0e6de00a | ||
|
|
8ff1194b6a | ||
|
|
9dd4ad6c1f | ||
|
|
4e398e2aa9 | ||
|
|
92401faa72 | ||
|
|
edc46281a4 | ||
|
|
6c8b3e3b58 | ||
|
|
1faf0ab9e3 | ||
|
|
e6ec23d7cc | ||
|
|
e2cd201f6a | ||
|
|
7e447c83fb | ||
|
|
0c0e8d6544 | ||
|
|
a4d14722f3 | ||
|
|
8020ba2dc5 | ||
|
|
21bbc9a81a | ||
|
|
bfe24b138d | ||
|
|
f3dbd986cb | ||
|
|
ecce865cfe | ||
|
|
4a6f60937a | ||
|
|
cbe9b050a9 | ||
|
|
2d5908f4de | ||
|
|
298d5cf042 | ||
|
|
853765954e | ||
|
|
7a99d73092 | ||
|
|
7077d51f1f | ||
|
|
270c7c1110 | ||
|
|
2d3a64815f | ||
|
|
86dc53b72a | ||
|
|
649d43c2c5 | ||
|
|
6d9b44e243 | ||
|
|
e864ba6c91 | ||
|
|
0686380302 | ||
|
|
282e9ead17 | ||
|
|
1f08a5e5f5 | ||
|
|
c41508cc8d | ||
|
|
187df4464e | ||
|
|
c94d640e2a | ||
|
|
cf998b7bf8 | ||
|
|
1a104762ea | ||
|
|
2a5209bb5a | ||
|
|
ebd167b658 | ||
|
|
c13ec867c9 | ||
|
|
199648ff37 | ||
|
|
536f2e42d2 | ||
|
|
0f9799d7e0 | ||
|
|
b1a4b00091 | ||
|
|
c1c9983cfe | ||
|
|
8980c3f74e | ||
|
|
418f57dd6a | ||
|
|
9ef005454a | ||
|
|
afad35a8ac | ||
|
|
2ca113a218 | ||
|
|
911ee4d9f9 | ||
|
|
9804b25acc | ||
|
|
87e16a8f47 | ||
|
|
e561c7b49d | ||
|
|
8cd65eaf46 | ||
|
|
b7ef6077df | ||
|
|
cb71d6d393 | ||
|
|
79c00be516 | ||
|
|
949efb414a | ||
|
|
5dd1256769 | ||
|
|
c52ef1d2b3 | ||
|
|
c7e91d3302 | ||
|
|
c1bbcf5ed3 | ||
|
|
87c5a61d07 | ||
|
|
0aa3d89134 | ||
|
|
4ffafdeb86 | ||
|
|
0bf32b957d | ||
|
|
2bdd916b06 | ||
|
|
93c487fb75 | ||
|
|
036d1aae50 | ||
|
|
f600a868f5 | ||
|
|
95f2d48ac4 | ||
|
|
8c847a85ae | ||
|
|
c265fa3331 | ||
|
|
6aab0332e8 | ||
|
|
47ae677652 | ||
|
|
54e1b79ac5 | ||
|
|
6afe1f3597 | ||
|
|
4466260480 | ||
|
|
1c6e31173d | ||
|
|
939180c1a1 | ||
|
|
8205737fdb | ||
|
|
75d4c9b446 | ||
|
|
e3cd1ac1f9 | ||
|
|
027a70a415 | ||
|
|
3dfe5f993b | ||
|
|
f5991dd9b6 | ||
|
|
58c5d008d5 | ||
|
|
ac1149156d | ||
|
|
ca866c0d7d | ||
|
|
90a3f88c08 | ||
|
|
c1f89c5640 | ||
|
|
5865a78c1e | ||
|
|
d4616a7fc6 | ||
|
|
d794357504 | ||
|
|
79b0484e20 | ||
|
|
62b4741b19 | ||
|
|
327f06bbaf | ||
|
|
d7cd90b5b8 | ||
|
|
85fef90c94 | ||
|
|
fca25479ad | ||
|
|
231d965bcb | ||
|
|
6c10282f9a | ||
|
|
cb399272fd | ||
|
|
245bce04d1 | ||
|
|
3101bdf127 | ||
|
|
384ae9c407 | ||
|
|
c671f8e7ef | ||
|
|
f39b9c85fe | ||
|
|
ab36270885 | ||
|
|
bd65dd8098 | ||
|
|
36b6f308e6 | ||
|
|
cd208314e0 | ||
|
|
da7b5135de | ||
|
|
cb3d2b327a | ||
|
|
48db3a3e92 | ||
|
|
7182fb8fb0 | ||
|
|
d7da390ae9 | ||
|
|
54c1025ec0 | ||
|
|
5e7b7cba31 | ||
|
|
5a6b1cbf66 | ||
|
|
180e6d2c75 | ||
|
|
acbf25f2eb | ||
|
|
7c90cc6aac | ||
|
|
261af8dc07 | ||
|
|
2f344268ff | ||
|
|
42f3c24fc4 | ||
|
|
c4b97a1710 | ||
|
|
4f76bc42d7 | ||
|
|
fbd5600563 | ||
|
|
3259e2eac9 | ||
|
|
baca292f47 | ||
|
|
8babf0ec73 | ||
|
|
c07d124d4b | ||
|
|
a0db1eaa32 | ||
|
|
dbd61d129d | ||
|
|
21b5fb5ddb | ||
|
|
f55fafbc66 | ||
|
|
768843f1f0 | ||
|
|
cc7d1226ee | ||
|
|
8abafc54a6 | ||
|
|
885695fa67 | ||
|
|
e0bf309bb5 | ||
|
|
d907bcd57a | ||
|
|
0167bbb89a | ||
|
|
0471aaec52 | ||
|
|
18636a4df5 | ||
|
|
2be122875a | ||
|
|
c517f6daf9 | ||
|
|
07223bf5ef | ||
|
|
7862ba583e | ||
|
|
8c10d91135 | ||
|
|
c81d0f3393 | ||
|
|
0b8b9e8033 | ||
|
|
b73198d5ef | ||
|
|
4236699052 | ||
|
|
75935ad251 | ||
|
|
a3c3f47e17 | ||
|
|
17f07a36ef | ||
|
|
557a0c7ae3 | ||
|
|
1b98df4a0d | ||
|
|
58bfb0458e | ||
|
|
95cbf95c50 | ||
|
|
0b4402ebc8 | ||
|
|
d64b3f21e6 | ||
|
|
931fcfd0f5 | ||
|
|
a6ca9aa306 | ||
|
|
40ef282982 | ||
|
|
9152d6671c | ||
|
|
d057e95ce3 | ||
|
|
ac2932bac3 | ||
|
|
118331207b | ||
|
|
7c104c8fbb | ||
|
|
11c94b6566 | ||
|
|
c555b532a2 | ||
|
|
fdc4c25e67 | ||
|
|
083134bc12 | ||
|
|
f1c4a9ebfa | ||
|
|
1edd2ed3db | ||
|
|
b8b04271b5 | ||
|
|
f0b33f5ced | ||
|
|
42eead8f41 | ||
|
|
33054a18db | ||
|
|
f4036e8352 | ||
|
|
f9c30017b0 | ||
|
|
8be76ed450 | ||
|
|
328b25d561 | ||
|
|
9eff9676e9 | ||
|
|
a1d8335a8c | ||
|
|
d5a174364a | ||
|
|
62c3de30b9 | ||
|
|
ebcb46cd48 | ||
|
|
1689361ff2 | ||
|
|
05e177e2c8 | ||
|
|
eb998bda62 | ||
|
|
116bcb9dfb | ||
|
|
6a452951f5 | ||
|
|
a891854ef5 | ||
|
|
a2dffd430b | ||
|
|
4ac0580aa0 | ||
|
|
5d872b26a1 | ||
|
|
8d2c8065eb | ||
|
|
bf176ed712 | ||
|
|
eb875de67e | ||
|
|
2a77b9fcc7 | ||
|
|
9a4a5b1816 | ||
|
|
3a0ab861c2 | ||
|
|
fdc0d30337 | ||
|
|
96e4ec4a15 | ||
|
|
fa4b711495 | ||
|
|
0113b735ad | ||
|
|
d228ff0f43 | ||
|
|
9abbb581c5 | ||
|
|
d7c50f56d7 | ||
|
|
b6750de9e8 | ||
|
|
c91caa06d3 | ||
|
|
6c3c184bc7 | ||
|
|
af71292aba | ||
|
|
24e29cecae | ||
|
|
ab4c3a326f | ||
|
|
d73ca29a07 | ||
|
|
d6fbe45296 | ||
|
|
dd1cd5e491 | ||
|
|
2b02db2675 | ||
|
|
6f93a8f091 | ||
|
|
47074c897e | ||
|
|
2270f0d172 | ||
|
|
1b5d3466ba | ||
|
|
dcc2247a90 | ||
|
|
00b7aeb49b | ||
|
|
4f5b781b88 | ||
|
|
b51d1b79a3 | ||
|
|
4848de3a8e | ||
|
|
88b1cebe1d | ||
|
|
bb9e9e5480 | ||
|
|
786a7fbaf4 | ||
|
|
0ce27296aa | ||
|
|
a1d176b643 | ||
|
|
0c18e653e8 | ||
|
|
065b8c945b | ||
|
|
f49fc35f55 | ||
|
|
67795ad26e | ||
|
|
2aef8bad55 | ||
|
|
9f05cabf87 | ||
|
|
4c07b1606c | ||
|
|
d3f0a3211d | ||
|
|
ec7333d406 | ||
|
|
6a40426421 | ||
|
|
c9ebb895a1 | ||
|
|
f66bbda8b1 | ||
|
|
da2d9f3733 | ||
|
|
9e0252b209 | ||
|
|
531ea17088 | ||
|
|
e89f5983be | ||
|
|
6784fd64f3 | ||
|
|
ced2543be0 | ||
|
|
261e92c57b | ||
|
|
55bd48dc10 | ||
|
|
96dc30dea2 | ||
|
|
ea7b0052f3 | ||
|
|
1db9013bc4 | ||
|
|
060cbe15d6 | ||
|
|
8532d0d152 | ||
|
|
173e63f01b | ||
|
|
066daf21ef | ||
|
|
10f4604939 | ||
|
|
08ab2d89f4 | ||
|
|
775deefeaa | ||
|
|
cbf281589b | ||
|
|
f1d95379bc | ||
|
|
7c4377af0e | ||
|
|
f93b8fe377 | ||
|
|
978c68dcf8 | ||
|
|
c0925d2d04 | ||
|
|
15e8208457 | ||
|
|
d8fe18c28e | ||
|
|
9ee85fb1b6 | ||
|
|
bdbc96f453 | ||
|
|
5f7831b3c8 | ||
|
|
6336279ce0 | ||
|
|
ab4b59afb9 | ||
|
|
046a270156 | ||
|
|
2f293d53ba | ||
|
|
1d7caed340 | ||
|
|
5993c816d8 | ||
|
|
15ccac78d9 | ||
|
|
d81841f54e | ||
|
|
95f4c02381 | ||
|
|
df0e4492a7 | ||
|
|
e01f342048 | ||
|
|
792f5b3f22 | ||
|
|
a42baedc28 | ||
|
|
6607cab902 | ||
|
|
3a09de82e3 | ||
|
|
c028619cdd | ||
|
|
6b1dc21383 | ||
|
|
613acd93c0 | ||
|
|
837cb42679 | ||
|
|
0e9cb48ea1 | ||
|
|
090aaefb39 | ||
|
|
0b9c9f9ede | ||
|
|
8e65fb920f | ||
|
|
945460c67e | ||
|
|
b7e4d2a8ff | ||
|
|
9768657fc7 | ||
|
|
a185e19bc1 | ||
|
|
b7603f8600 | ||
|
|
d8d281281c | ||
|
|
5ee9c95ebd | ||
|
|
fb5a1a2c0f | ||
|
|
4a5a7ee922 | ||
|
|
d258bc263a | ||
|
|
8a30754e9c | ||
|
|
a14bc9ed44 | ||
|
|
75adf4bac6 | ||
|
|
8d6013454c | ||
|
|
1a25062af0 | ||
|
|
8aedcadd3e | ||
|
|
027d59fd46 | ||
|
|
273e70e403 | ||
|
|
aee6c1f72f | ||
|
|
9ee40d9f88 | ||
|
|
754fe60979 | ||
|
|
3a429eabcd | ||
|
|
9209a2ee33 | ||
|
|
3a607a197e | ||
|
|
3639daa329 | ||
|
|
8fd6a61df6 | ||
|
|
a6b0d40f9d | ||
|
|
974cf08e5d | ||
|
|
75fd6fc4a4 | ||
|
|
4f7dc3c76c | ||
|
|
7abfe74fa4 | ||
|
|
d5a159d7af | ||
|
|
add68e0da1 | ||
|
|
a85f9db5b1 | ||
|
|
c43ab76bbe | ||
|
|
98df3c6e0a | ||
|
|
0a4130a4ff | ||
|
|
93828fde80 | ||
|
|
a3fdc33f88 | ||
|
|
a330917ee8 | ||
|
|
0fe5dd8d43 | ||
|
|
953d783a3e | ||
|
|
d1ef610822 | ||
|
|
2ff620e1b5 | ||
|
|
0aaf69769f | ||
|
|
b5ab0c5285 | ||
|
|
2442b985bf | ||
|
|
78201c0146 | ||
|
|
499f4689be | ||
|
|
2106f491d0 | ||
|
|
81ac03a28b | ||
|
|
980af63b8d | ||
|
|
613644bfc6 | ||
|
|
7f5d6bc964 | ||
|
|
d5e37309e5 | ||
|
|
6bfa99a774 | ||
|
|
c899097802 | ||
|
|
70187bd47e | ||
|
|
018efc9631 | ||
|
|
a4f4e6e71d | ||
|
|
cde11f9d9c | ||
|
|
8fa3b6802e | ||
|
|
4192df97ec | ||
|
|
9085abd838 | ||
|
|
874415a193 | ||
|
|
5e9d80fbdb | ||
|
|
75f7f21eb0 | ||
|
|
c01e265e07 | ||
|
|
5c89228878 | ||
|
|
2740a81103 | ||
|
|
a27dc1e908 | ||
|
|
e9abfa6602 | ||
|
|
0f8a2d6418 | ||
|
|
2e479b88a8 | ||
|
|
fd982597fe | ||
|
|
887077b5a4 | ||
|
|
4e71ec4480 | ||
|
|
8ef712787a | ||
|
|
6c39b8a10c | ||
|
|
3c32c993f5 | ||
|
|
62d705903e | ||
|
|
a5e2e9ea03 | ||
|
|
055e3d52b6 | ||
|
|
efd3104fd0 | ||
|
|
bd570561e8 | ||
|
|
19d49db305 | ||
|
|
ab4993fda2 | ||
|
|
6f4056cf99 | ||
|
|
9cf1390dc6 | ||
|
|
6a2e323792 | ||
|
|
d4834803ae | ||
|
|
84fc489e0c | ||
|
|
255d5a748f | ||
|
|
b41520f9e2 | ||
|
|
0e881170c2 | ||
|
|
1571881f7a | ||
|
|
4dbf1dcad4 | ||
|
|
824ef1ff2c | ||
|
|
79d9b36ece | ||
|
|
be316e81a7 | ||
|
|
615e52d396 | ||
|
|
7f232b43ff | ||
|
|
5a12aeb4a1 | ||
|
|
05ea5f05ae | ||
|
|
e895aa71a4 | ||
|
|
eb28133b1f | ||
|
|
c66932ab25 | ||
|
|
36e8213e42 | ||
|
|
cde6d0deed | ||
|
|
b462cb4575 | ||
|
|
dd4ccfc672 | ||
|
|
6006e2f917 | ||
|
|
4bedb07aa0 | ||
|
|
02e194b15f | ||
|
|
82e579a29d | ||
|
|
eacac8ee1d | ||
|
|
cd19d81411 | ||
|
|
748ba22a19 | ||
|
|
79be888b6f | ||
|
|
58b3b0603d | ||
|
|
9d43d74ee3 | ||
|
|
9bc49b3268 | ||
|
|
d92e0dec22 | ||
|
|
7932bf483b | ||
|
|
e54f3fdaac | ||
|
|
e8b055b8d3 | ||
|
|
0c94f22ded | ||
|
|
05909d6fa7 | ||
|
|
712a22e18c | ||
|
|
35893e36dd | ||
|
|
787eecbf43 | ||
|
|
5f1aac1450 | ||
|
|
7fdd312cca | ||
|
|
f16911f7dd | ||
|
|
f6bdd2cae4 | ||
|
|
f8aa14d402 | ||
|
|
11a4f5538b | ||
|
|
26e88dc2c1 | ||
|
|
34fcccc50b | ||
|
|
2f53df93e8 | ||
|
|
996d5fda69 | ||
|
|
f75be85eea | ||
|
|
f1412f5e5a | ||
|
|
4208bcd8d1 | ||
|
|
5368a760cf | ||
|
|
9ec08fa76a | ||
|
|
913a99dd35 | ||
|
|
d956a39fec | ||
|
|
01d9bd573e | ||
|
|
d301b69dae | ||
|
|
c1fe7517ec | ||
|
|
cd1c96db56 | ||
|
|
4aee4c1ac7 | ||
|
|
bef0503545 | ||
|
|
7aea2cd6f1 | ||
|
|
028d707077 | ||
|
|
c9df03d1a9 | ||
|
|
19338d2774 | ||
|
|
005e5f2f72 | ||
|
|
e54cd23ecb | ||
|
|
544e469eeb | ||
|
|
db739d16ce | ||
|
|
5fff6e7ff8 | ||
|
|
776c01e60b | ||
|
|
3eb38d7611 | ||
|
|
766159e27e | ||
|
|
bb34d8cfd1 | ||
|
|
a880469d7d | ||
|
|
e5147d5562 | ||
|
|
d7ff85850c | ||
|
|
7294cb080b | ||
|
|
b422864d5d | ||
|
|
eab3667b61 | ||
|
|
713e89cdb2 | ||
|
|
b290f0442d | ||
|
|
b035a6196a | ||
|
|
e4cd00b5ea | ||
|
|
3bb13829fe | ||
|
|
1af676385c | ||
|
|
a24a170b84 | ||
|
|
bc4b3764fc | ||
|
|
9b143dd5dc | ||
|
|
5c65d4733b | ||
|
|
41a84ef1d3 | ||
|
|
86cecd6700 | ||
|
|
fdcb87db19 | ||
|
|
a868832776 | ||
|
|
5eabd4591a | ||
|
|
91afefa61a | ||
|
|
ea7bdb8e9e | ||
|
|
7cda728469 | ||
|
|
7fd37d4e87 | ||
|
|
874bfe19d2 | ||
|
|
ed07d481d6 | ||
|
|
7115975212 | ||
|
|
ddf0982d0f | ||
|
|
7b54ddd828 | ||
|
|
1ffd049833 | ||
|
|
12e0a2ef7d | ||
|
|
9da7afb345 | ||
|
|
1f544e087b | ||
|
|
e1b6a4cb21 | ||
|
|
bb8522b737 | ||
|
|
e075581d76 | ||
|
|
527d18a526 | ||
|
|
5ace5976a1 | ||
|
|
c52ac01fbc | ||
|
|
f4f2bfe379 | ||
|
|
75beb3bd35 | ||
|
|
1d22294974 | ||
|
|
de665f7cf9 | ||
|
|
205520c620 | ||
|
|
3551b2a2a1 | ||
|
|
11f2e8d1a6 | ||
|
|
a91374a916 | ||
|
|
36e6c26545 | ||
|
|
9a68f74857 | ||
|
|
b96c15890c | ||
|
|
5a6b26d69e | ||
|
|
a3d912a801 | ||
|
|
b4f1deaa46 | ||
|
|
976bce4c7f | ||
|
|
77e0f77850 | ||
|
|
a885cbf8ed | ||
|
|
b6af5d9bda | ||
|
|
b72677c3ce | ||
|
|
5e44122552 | ||
|
|
d4b6471d39 | ||
|
|
fe1bea9538 | ||
|
|
2f41e2b0ec | ||
|
|
bd86f95512 | ||
|
|
5fcf6418cf | ||
|
|
4e583dab2e | ||
|
|
bc182cab7c | ||
|
|
f6f6f11838 | ||
|
|
b5f4672155 | ||
|
|
729da3c873 | ||
|
|
8a31c6f807 | ||
|
|
2539b5cf61 | ||
|
|
f7881e58bb | ||
|
|
25ed4e9d16 | ||
|
|
7eddf93b36 | ||
|
|
cfb082a20b | ||
|
|
e440590c37 | ||
|
|
c851a19ab2 | ||
|
|
c2f9d7dee0 | ||
|
|
473e567047 | ||
|
|
64dab92c6b | ||
|
|
f576755b13 | ||
|
|
d0f279ece4 | ||
|
|
a5532ffd4d | ||
|
|
cb412134dd | ||
|
|
d079aae0e0 | ||
|
|
eabfb233b8 | ||
|
|
960e724ad3 | ||
|
|
82c46f957a | ||
|
|
320ea29861 | ||
|
|
c5e99ada63 | ||
|
|
c5bd3f5e3b | ||
|
|
a88d054d05 | ||
|
|
6576802287 | ||
|
|
693316c83f | ||
|
|
41ff80e5d3 | ||
|
|
56c5fdbeaf | ||
|
|
130d39cc03 | ||
|
|
1485edf8e1 | ||
|
|
514ee867a6 | ||
|
|
3cc7a406f4 | ||
|
|
c3f82acf7a | ||
|
|
cdb7557d88 | ||
|
|
2dcbd016e6 | ||
|
|
7d1728f05a | ||
|
|
4b5c14470a | ||
|
|
f198b11f27 | ||
|
|
7d16087789 | ||
|
|
d734cd986c | ||
|
|
8559f3e583 | ||
|
|
d0b81d3b20 | ||
|
|
43bf9a8e46 | ||
|
|
19f57bf810 | ||
|
|
469012b544 | ||
|
|
9b11c4670d | ||
|
|
7eeaf8eaa5 | ||
|
|
a82e02ef15 | ||
|
|
d8922d0410 | ||
|
|
5c628d2a61 | ||
|
|
54bb20b486 | ||
|
|
57a6eaae7b | ||
|
|
7a5cb21056 | ||
|
|
333c3f18c0 | ||
|
|
6b2979027e | ||
|
|
12f9adbdd3 | ||
|
|
a5cab96ff3 | ||
|
|
dd060ceed3 | ||
|
|
c89b085e5b | ||
|
|
63140ca7f8 | ||
|
|
cbe83f32b6 | ||
|
|
3bffb0a181 | ||
|
|
09dc9c89a8 | ||
|
|
09707a3e81 | ||
|
|
d821277430 | ||
|
|
1f01634029 | ||
|
|
dd314e1bdf | ||
|
|
1dae102359 | ||
|
|
b306594cad | ||
|
|
b60b7cf8fe | ||
|
|
0148128881 | ||
|
|
076a884651 | ||
|
|
7026bbcdd4 | ||
|
|
6158aa684b | ||
|
|
047e3455f7 | ||
|
|
9ca9649c1b | ||
|
|
9a23e9839b | ||
|
|
7fc966dced | ||
|
|
680afa4229 | ||
|
|
313743c833 | ||
|
|
6cb19d7e34 | ||
|
|
ef0575a26d | ||
|
|
c9db715bae | ||
|
|
ed1e3899af | ||
|
|
7446e31fce | ||
|
|
94abf9d935 | ||
|
|
d9b4ab1658 | ||
|
|
39f8538776 | ||
|
|
fef5c4c9a0 | ||
|
|
61dc2e7dd5 | ||
|
|
11a820458f | ||
|
|
9e7418090d | ||
|
|
0b3b713123 | ||
|
|
00f8cf57cd | ||
|
|
c55c375b0a | ||
|
|
db76ca248b | ||
|
|
182e1909b2 | ||
|
|
3aea7bc053 | ||
|
|
39c35732de | ||
|
|
6c8850698d | ||
|
|
818a726679 | ||
|
|
f8663a7129 | ||
|
|
7571fe5d13 | ||
|
|
60dc1c22f7 | ||
|
|
02b575e9e4 | ||
|
|
6facaf8f05 | ||
|
|
319a972e75 | ||
|
|
61cdbb30a6 | ||
|
|
5088a38b9f | ||
|
|
f5c6a6d075 | ||
|
|
b5340dd739 | ||
|
|
e1dcfcbb76 | ||
|
|
43d448e73f | ||
|
|
33fbb06604 | ||
|
|
e1b215aa73 | ||
|
|
6a17ef925d | ||
|
|
7599985a0a | ||
|
|
07c0bc288a | ||
|
|
f05d392920 | ||
|
|
e11d57c883 | ||
|
|
baf377679a | ||
|
|
f9355136d8 | ||
|
|
bb76e69567 | ||
|
|
533fc217d4 | ||
|
|
ac5c6695c1 | ||
|
|
3160488352 | ||
|
|
8579e4144f | ||
|
|
6880fa62f8 | ||
|
|
2cf4287197 | ||
|
|
86c774443c | ||
|
|
3b715f4602 | ||
|
|
ec0c2bea6e | ||
|
|
1b3682cfa9 | ||
|
|
2a9ee35411 | ||
|
|
0e0a7d82de | ||
|
|
dfa96852f0 | ||
|
|
a549ec0382 | ||
|
|
c61f01b206 | ||
|
|
15257f4524 | ||
|
|
089378ef87 | ||
|
|
805f495d84 | ||
|
|
928dd94ba6 | ||
|
|
b429918b32 | ||
|
|
62a37a4876 | ||
|
|
0e96ece6c6 | ||
|
|
f1eca32536 | ||
|
|
ed59dc1ada | ||
|
|
a5cd3fcafd | ||
|
|
f3def542ee | ||
|
|
aa249922df | ||
|
|
37a0c57bed | ||
|
|
90b7e68b4e | ||
|
|
1a0c497007 | ||
|
|
fd49ee3c8d | ||
|
|
3488a5c3c4 | ||
|
|
ae4955f59e | ||
|
|
fab107a9df | ||
|
|
bb87d19e84 | ||
|
|
4e309b7992 | ||
|
|
64aa4c716d | ||
|
|
6b0852a21f | ||
|
|
8afd3e882e | ||
|
|
791fa28817 | ||
|
|
3fab752640 | ||
|
|
67dd939d83 | ||
|
|
ec9b447be1 | ||
|
|
99e3fe9ae1 | ||
|
|
eb99d21022 | ||
|
|
793cbcdff8 | ||
|
|
751557bcbf | ||
|
|
252dcd8626 | ||
|
|
0ad7ea16d2 | ||
|
|
79842d4fdd | ||
|
|
1e1f5d5462 | ||
|
|
19d8ffe177 | ||
|
|
4cb8192c1d | ||
|
|
2ed5bc5195 | ||
|
|
fae1397468 | ||
|
|
e871548772 | ||
|
|
a3d27e30e0 | ||
|
|
89abd1f58e | ||
|
|
fae709d9ea | ||
|
|
36df79b207 | ||
|
|
b9ebcd7738 | ||
|
|
515fb5a3fd | ||
|
|
785f90d9fa | ||
|
|
22ac311496 | ||
|
|
0e31ca73c0 | ||
|
|
98ba558fa5 | ||
|
|
c4ef1e5c19 | ||
|
|
1fa0d66f15 | ||
|
|
4680307a34 | ||
|
|
42a6fa972d | ||
|
|
1da6c35a6d | ||
|
|
7c427a4dce | ||
|
|
c2abae538b | ||
|
|
eb69032773 | ||
|
|
fb5452910f | ||
|
|
a6d37fcb25 | ||
|
|
fb18e1f036 | ||
|
|
786cbee510 | ||
|
|
a4f5673ff3 | ||
|
|
1121f2b7f7 | ||
|
|
4d30218eb2 | ||
|
|
d7699ca81d | ||
|
|
afc3bc6b65 | ||
|
|
6f066fca82 | ||
|
|
5e24ae49a6 | ||
|
|
bf74ffe974 | ||
|
|
2074861b57 | ||
|
|
58b64d42f1 | ||
|
|
a6ab0405ea | ||
|
|
8273b54108 | ||
|
|
c356f560e8 | ||
|
|
8d052ecf24 | ||
|
|
45e36d9f56 | ||
|
|
c222d8b672 | ||
|
|
efed3f1f0d | ||
|
|
7524893802 | ||
|
|
25a0273b05 | ||
|
|
ce0410b205 | ||
|
|
efe5ce5c78 | ||
|
|
07f52b4b96 | ||
|
|
0be3598990 | ||
|
|
c3284c30cd | ||
|
|
2d94bf4998 | ||
|
|
31c1e72b8c | ||
|
|
d11fcafad8 | ||
|
|
27c6d299cf | ||
|
|
450dd65165 | ||
|
|
26819e6c39 | ||
|
|
6587efb3e8 | ||
|
|
8d2200f29b | ||
|
|
e4295396ac | ||
|
|
5c7a70df28 | ||
|
|
16a7a8258f | ||
|
|
fb1f61b212 | ||
|
|
c3137df39c | ||
|
|
2df9cd7262 | ||
|
|
a23f6afbee | ||
|
|
e37f7fafc1 | ||
|
|
7b803465ad | ||
|
|
273612b251 | ||
|
|
e2bc8e86e2 | ||
|
|
79110ba469 | ||
|
|
9dd10e46ab | ||
|
|
29df95c514 | ||
|
|
015cb1a35d | ||
|
|
b217b020a5 | ||
|
|
0c960a82ce | ||
|
|
e84cc8c0ad | ||
|
|
c69b93b246 | ||
|
|
5e13b9528d | ||
|
|
8bb3cab9d2 | ||
|
|
ed201c35d2 | ||
|
|
4eadc22a36 | ||
|
|
4e2260c74c | ||
|
|
a5148c14a1 | ||
|
|
955d6206ee | ||
|
|
5df22b3468 | ||
|
|
aef86ec5ef | ||
|
|
94d3b04d68 | ||
|
|
d31830225c | ||
|
|
8f309a3fec | ||
|
|
1fe4edbe1c | ||
|
|
fe1696cef7 | ||
|
|
de2e311e6e | ||
|
|
384fb3c353 | ||
|
|
8603e19516 | ||
|
|
7a2751043a | ||
|
|
e2b0c6c702 | ||
|
|
5b12c61a81 | ||
|
|
b8ee8808b4 | ||
|
|
2db9551750 | ||
|
|
7dc51270ee | ||
|
|
237b5a2467 | ||
|
|
110e5af36c | ||
|
|
7d4aef9576 | ||
|
|
811b360df7 | ||
|
|
d91b54882a | ||
|
|
9106a1f2d5 | ||
|
|
2e2dada561 | ||
|
|
6d704c728e | ||
|
|
6c6f32f17f | ||
|
|
0e4ce326c2 | ||
|
|
d27448da8a | ||
|
|
d36b723056 | ||
|
|
2c8aa6f6f4 | ||
|
|
6f7c8fb355 | ||
|
|
82f852abf3 | ||
|
|
239c6fe070 | ||
|
|
579d2ad811 | ||
|
|
0cb355cd7c | ||
|
|
86135d12b9 | ||
|
|
10d42c6fa3 | ||
|
|
6434f7efad | ||
|
|
bfdf19f56c | ||
|
|
79c7a7a43d | ||
|
|
175053085a | ||
|
|
3d90c062fd | ||
|
|
fda71b1230 | ||
|
|
a916de3b66 | ||
|
|
30e5dfddb9 | ||
|
|
f9dea9d35b | ||
|
|
4ea55b1bbc | ||
|
|
caf3c16826 | ||
|
|
a6f1111469 | ||
|
|
33d0096b81 | ||
|
|
ed4c5d88a3 | ||
|
|
e85a892111 | ||
|
|
70cd10beae | ||
|
|
3a784509df | ||
|
|
5c7189124c | ||
|
|
f81c2744cc | ||
|
|
4bf3359574 | ||
|
|
47984b0496 | ||
|
|
3c339323ed | ||
|
|
7399722a88 | ||
|
|
7bfea6edb7 | ||
|
|
f75da2c393 | ||
|
|
475576ec20 | ||
|
|
f6a8e1df03 | ||
|
|
e1c4bfad05 | ||
|
|
1ed40e7983 | ||
|
|
035fcce9de | ||
|
|
19eed5ff8a | ||
|
|
7129d4797c | ||
|
|
707d31a083 | ||
|
|
79e66ac841 | ||
|
|
1b96391cdf | ||
|
|
eed8ea5bc1 | ||
|
|
a646b5374f | ||
|
|
fa9b1ba947 | ||
|
|
7d58c0c2be | ||
|
|
3c71c378bc | ||
|
|
e4a6d199fe | ||
|
|
bdfdc2bb83 | ||
|
|
351e590e01 | ||
|
|
45756246b9 | ||
|
|
611fb3a1f9 | ||
|
|
ec1c2a714e | ||
|
|
55f64f13c7 | ||
|
|
bbc33080e7 | ||
|
|
506a57392c | ||
|
|
f0e0e72e4d | ||
|
|
7108c57876 | ||
|
|
49873ee687 | ||
|
|
cea2c0bbc4 | ||
|
|
93dfcdce93 | ||
|
|
ba786dc49b | ||
|
|
af384440f8 | ||
|
|
8014551908 | ||
|
|
c699921ff0 | ||
|
|
df99ce9d98 | ||
|
|
829744dfe6 | ||
|
|
734400cafa | ||
|
|
b306cab8be | ||
|
|
031a4cbdd8 | ||
|
|
0fc282e182 | ||
|
|
1eaf425627 | ||
|
|
326b8ff728 | ||
|
|
9ed2b7e03c | ||
|
|
08703f46f8 | ||
|
|
ea08652416 | ||
|
|
26d9b28f77 | ||
|
|
2bfd55fd69 | ||
|
|
39a6db4097 | ||
|
|
ff63557d39 | ||
|
|
4c7290fed0 | ||
|
|
31776e23fe | ||
|
|
6719f10034 | ||
|
|
b0273c9209 | ||
|
|
4ae13c6c26 | ||
|
|
cf7054dff2 | ||
|
|
b8eeee5528 | ||
|
|
30d5b11628 | ||
|
|
cd65d36822 | ||
|
|
cda867d52b | ||
|
|
24a9063721 | ||
|
|
840953c0e3 | ||
|
|
398bf575d9 | ||
|
|
8bfe344923 | ||
|
|
c3fa5819fd | ||
|
|
7e73e4728d | ||
|
|
03bc7c868b | ||
|
|
4c3f44b0d2 | ||
|
|
b031be753a | ||
|
|
6e9c995fc8 | ||
|
|
6ee1644db7 | ||
|
|
7cb64f2a43 | ||
|
|
6c907ce8d1 | ||
|
|
a0eb47d561 | ||
|
|
084c45d3db | ||
|
|
0ef3b9b3c5 | ||
|
|
ea5cd98e83 | ||
|
|
12bb78a425 | ||
|
|
042b2a39d9 | ||
|
|
1204e461c8 | ||
|
|
9bc16878ea | ||
|
|
7662015de6 | ||
|
|
e4775d4162 | ||
|
|
e147801ed8 | ||
|
|
ed14a32224 | ||
|
|
4ecb01f4fd | ||
|
|
a1efd95d0f | ||
|
|
ac2b4c2174 | ||
|
|
9ef5a61b1e | ||
|
|
b68c91c973 | ||
|
|
710ac00024 | ||
|
|
a96a12ed1f | ||
|
|
a8976fd367 | ||
|
|
11e0cf6f40 | ||
|
|
dc1ac6107f | ||
|
|
f9538c9395 | ||
|
|
445a64d933 | ||
|
|
d1940302bb | ||
|
|
3defc437c6 | ||
|
|
40f10b69f7 | ||
|
|
4c5117101d | ||
|
|
4bcfd81923 | ||
|
|
f6a8994521 | ||
|
|
0eb3d92782 | ||
|
|
50f47f18c1 | ||
|
|
18a215e6a8 | ||
|
|
0bce6f8974 | ||
|
|
be7275c238 | ||
|
|
1254b42e66 | ||
|
|
a389b630ac | ||
|
|
a4a7a7a47e | ||
|
|
a3087737bd | ||
|
|
12fc0239c2 | ||
|
|
0418edb7b6 | ||
|
|
2e233cb35b | ||
|
|
e36394e6cc | ||
|
|
6d3149714f | ||
|
|
f651747a89 | ||
|
|
9ea10ce05d | ||
|
|
dbad0d5723 | ||
|
|
21d17e41fd | ||
|
|
af8f280811 | ||
|
|
7abb278b60 | ||
|
|
7842a0190a | ||
|
|
a22e66f5ee | ||
|
|
1a72feb128 | ||
|
|
132b09ce09 | ||
|
|
a28af1be11 | ||
|
|
b04ac8f3be | ||
|
|
5f35f4bb3b | ||
|
|
4c3512c0a2 | ||
|
|
09ca7a181b | ||
|
|
82a32be1d6 | ||
|
|
9f3511231a | ||
|
|
6da25968e0 | ||
|
|
a70f478ef1 | ||
|
|
6c147709b6 | ||
|
|
8636ac26cf | ||
|
|
01a53d955e | ||
|
|
a5be8fe82c | ||
|
|
e6cc785fff | ||
|
|
00809b49f1 | ||
|
|
917f8ec799 | ||
|
|
37ff512516 | ||
|
|
c50f80da92 | ||
|
|
2bd3d51fcf | ||
|
|
2e0829fb5a | ||
|
|
c4ff244c4e | ||
|
|
002998cf49 | ||
|
|
7dea6dc834 | ||
|
|
fd0d94af44 | ||
|
|
ab630b2875 | ||
|
|
09aff62b11 | ||
|
|
f4f717b20a | ||
|
|
cf188ba15c | ||
|
|
fa34d51b7e | ||
|
|
6621f8b88a | ||
|
|
f9e4f4d813 | ||
|
|
80b961df60 | ||
|
|
cea002a088 | ||
|
|
e062b70da8 | ||
|
|
ce4dbcec6a | ||
|
|
07058652c1 | ||
|
|
7a92011933 | ||
|
|
c60d0de919 | ||
|
|
6457b93a1f | ||
|
|
20667e5163 | ||
|
|
74f2b5e5f7 | ||
|
|
96f2e162ef | ||
|
|
859f06a91e | ||
|
|
9cafc7a764 | ||
|
|
32d9f25a6f | ||
|
|
2f7e4bd587 | ||
|
|
84697ce713 | ||
|
|
0846206bc0 | ||
|
|
441e9b8431 | ||
|
|
f9f21934ab | ||
|
|
2673568cfd | ||
|
|
45c13ad08f | ||
|
|
76d395c8de | ||
|
|
090b4087fc | ||
|
|
7ece19c474 | ||
|
|
dbdd0f520f | ||
|
|
d47ef79c04 | ||
|
|
400ff200ee | ||
|
|
daeb21b3b9 | ||
|
|
7e36c58529 | ||
|
|
aa84869fdb | ||
|
|
bd6b1a0237 | ||
|
|
adf088e575 | ||
|
|
8613f2a48e | ||
|
|
12228ea34d | ||
|
|
f308f7cc80 | ||
|
|
eb1a41f3c9 | ||
|
|
ee2c049518 | ||
|
|
0ba9a45d32 | ||
|
|
bcfc7173f3 | ||
|
|
d390ca7056 | ||
|
|
18df3961e9 | ||
|
|
d372121d6e | ||
|
|
8e9aa84070 | ||
|
|
6319ffbcb8 | ||
|
|
d1c03cbd69 | ||
|
|
37629fc1b6 | ||
|
|
cc31bb9358 | ||
|
|
35ef1e1b86 | ||
|
|
d8d787545e | ||
|
|
0a51d72098 | ||
|
|
e13c78820f | ||
|
|
7f1becc682 | ||
|
|
1660e800e0 | ||
|
|
da40fbd054 | ||
|
|
90bc698a40 | ||
|
|
cb6cec0404 | ||
|
|
de29a0818e | ||
|
|
4fc309b1dd | ||
|
|
353478180d | ||
|
|
ea66eb6c23 | ||
|
|
7b3e158c92 | ||
|
|
848dea2058 | ||
|
|
f2d35751ca | ||
|
|
16833de1cf | ||
|
|
0cb0cd6611 | ||
|
|
dc49999124 | ||
|
|
daebdd1d77 | ||
|
|
c68ee2b2ed | ||
|
|
32fbec2e48 | ||
|
|
c13e08a7f5 | ||
|
|
451926e5c3 | ||
|
|
1868b2d244 | ||
|
|
dd2fa15e8a | ||
|
|
d2e008d4b4 | ||
|
|
98fbb855fb | ||
|
|
987e9df948 | ||
|
|
70d54479a1 | ||
|
|
c91b024153 | ||
|
|
f5f31f5eaa | ||
|
|
442f46a1ce | ||
|
|
ea6432702f | ||
|
|
faa9191191 | ||
|
|
8560f6ef2b | ||
|
|
b0c1e37364 | ||
|
|
bb0194cc0c | ||
|
|
304dc9fd07 | ||
|
|
bcfdf4c1cf | ||
|
|
663b79ca72 | ||
|
|
4a720425b7 | ||
|
|
0e4d59541a | ||
|
|
ba666295eb | ||
|
|
d34851db91 | ||
|
|
7dfd162a34 | ||
|
|
6d0a8a85c7 | ||
|
|
721d237120 | ||
|
|
46c575c038 | ||
|
|
16434f0d01 | ||
|
|
39edc69514 | ||
|
|
2154ac3ecb | ||
|
|
42309b5d6f | ||
|
|
07af438a38 | ||
|
|
fa8f6cb204 | ||
|
|
049853362a | ||
|
|
3e6202f614 | ||
|
|
a993e962f5 | ||
|
|
1ad5537c9b | ||
|
|
ea0dc429a7 | ||
|
|
8d7f09fa92 | ||
|
|
02a6a8a809 | ||
|
|
2bba9bcd9f | ||
|
|
4eebbdea0d | ||
|
|
4a2d03a517 | ||
|
|
5212afdd8f | ||
|
|
e196108931 | ||
|
|
a5e9b73703 | ||
|
|
5e13d495f0 | ||
|
|
a528a2323e | ||
|
|
c786f238ef | ||
|
|
d04f7aa4bc | ||
|
|
ced453a72b | ||
|
|
0f3e8c19e8 | ||
|
|
cc4df7100d | ||
|
|
0bd02a5f7a | ||
|
|
b311ab0d53 | ||
|
|
b6b905412e | ||
|
|
2c2fec1b0e | ||
|
|
f946abd86b | ||
|
|
156d2c866f | ||
|
|
ef68392388 | ||
|
|
51006824f9 | ||
|
|
9eebc135ce | ||
|
|
af0d6bc881 | ||
|
|
771fb0f2cd | ||
|
|
3984e521ad | ||
|
|
95c1bca3f1 | ||
|
|
4c1069c38b | ||
|
|
219266b7de | ||
|
|
f037bfad1e | ||
|
|
c0a8ef6f6f | ||
|
|
a071cbf86c | ||
|
|
6dd350348d | ||
|
|
5472d94b73 | ||
|
|
40abd14884 | ||
|
|
cac01f7a89 | ||
|
|
7ea512e7fa | ||
|
|
8bd53b5be8 | ||
|
|
96610c9c20 | ||
|
|
6972e81ac0 | ||
|
|
ac46dbacfa | ||
|
|
ea3b0fc477 | ||
|
|
99dfbfeef0 | ||
|
|
dcce504ade | ||
|
|
dfa0369678 | ||
|
|
1d341bae31 | ||
|
|
0ed4fd6741 | ||
|
|
6fc6acf295 | ||
|
|
bda378bb9f | ||
|
|
4619bbc3ea | ||
|
|
c73606309f | ||
|
|
0442c1e228 | ||
|
|
b0500b7b5a | ||
|
|
38581aad65 | ||
|
|
53148943bd | ||
|
|
cfab6dc28b | ||
|
|
a57c91404f | ||
|
|
8210edfeea | ||
|
|
c9bd32d12b | ||
|
|
dfe1ab7438 | ||
|
|
e26a3e347b | ||
|
|
29f5968c23 | ||
|
|
1b798ed6d3 | ||
|
|
dbac2ff0b3 | ||
|
|
f2fbcdf00a | ||
|
|
b8972f5701 | ||
|
|
8b9a303e21 | ||
|
|
6ef24c4e48 | ||
|
|
428293a69b | ||
|
|
1dd7e81df7 | ||
|
|
4beff6c2cf | ||
|
|
58d748a8ad | ||
|
|
43a06e8e37 | ||
|
|
8f2284d5c7 | ||
|
|
131eed412a | ||
|
|
330647dad8 | ||
|
|
ecf0f56d33 | ||
|
|
05a91a4725 | ||
|
|
4b9e035a9f | ||
|
|
f975754ad9 | ||
|
|
d31ef42acf | ||
|
|
f9129c4dcd | ||
|
|
1f1e6eb5a1 | ||
|
|
2382792792 | ||
|
|
8cdeaa5148 | ||
|
|
10bf9ef2ef | ||
|
|
bca526b634 | ||
|
|
9b76f5bf53 | ||
|
|
e41134bbbe | ||
|
|
b9353eaf12 | ||
|
|
3e62b75529 | ||
|
|
ad55cb6733 | ||
|
|
6c977ad6ed | ||
|
|
2b53babf99 | ||
|
|
8077dd838c | ||
|
|
c22eaf5f52 | ||
|
|
f1c0bbc62b | ||
|
|
e988d2ee0b | ||
|
|
72e3d22271 | ||
|
|
585b250540 | ||
|
|
a582ccfce8 | ||
|
|
6c979fed40 | ||
|
|
bb06293b30 | ||
|
|
50111c8689 | ||
|
|
6028e2c420 | ||
|
|
d6986a757a | ||
|
|
01cccf4aee | ||
|
|
4e4da8e019 | ||
|
|
2a3d00f1ed | ||
|
|
8b5fcad039 | ||
|
|
aa69784495 | ||
|
|
4933bfaaa0 | ||
|
|
ef6b7099ba | ||
|
|
1be416fe0e | ||
|
|
524bab33ba | ||
|
|
2a3e3b984d | ||
|
|
fc242e107d | ||
|
|
a7db4e4347 | ||
|
|
8fe9e007c9 | ||
|
|
05b8bf216c | ||
|
|
faf18b7f9a | ||
|
|
62b78bebe1 | ||
|
|
27dff9af70 | ||
|
|
43c6a550b2 | ||
|
|
814f8c505e | ||
|
|
fbd9fa5d94 | ||
|
|
28832ba9c2 | ||
|
|
6cb3ae7d7f | ||
|
|
bcb2600107 | ||
|
|
18ee2d90c9 | ||
|
|
fecc7424e4 | ||
|
|
9ede36a386 | ||
|
|
950f2d0f2f | ||
|
|
89bc334515 | ||
|
|
67e47cac49 | ||
|
|
58cb89d261 | ||
|
|
fea27fd743 | ||
|
|
d5ae18e468 | ||
|
|
129c4d20c7 | ||
|
|
76e851fc56 |
58
COPYING
58
COPYING
@@ -1,29 +1,33 @@
|
||||
Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the Institute nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
5
FILES
5
FILES
@@ -1,5 +1,4 @@
|
||||
src/ - The source code for the lwIP TCP/IP stack.
|
||||
doc/ - The documentation for lwIP.
|
||||
|
||||
proj/ - Makefiles and code for compiling lwIP.
|
||||
|
||||
See also the FILES file in each subdirectory.
|
||||
See also the FILES file in each subdirectory.
|
||||
|
||||
89
README
Normal file
89
README
Normal file
@@ -0,0 +1,89 @@
|
||||
INTRODUCTION
|
||||
|
||||
lwIP is a small independent implementation of the TCP/IP protocol
|
||||
suite that has been developed by Adam Dunkels at the Computer and
|
||||
Networks Architectures (CNA) lab at the Swedish Institute of Computer
|
||||
Science (SICS).
|
||||
|
||||
The focus of the lwIP TCP/IP implementation is to reduce the RAM usage
|
||||
while still having a full scale TCP. This making lwIP suitable for use
|
||||
in embedded systems with tens of kilobytes of free RAM and room for
|
||||
around 40 kilobytes of code ROM.
|
||||
|
||||
FEATURES
|
||||
|
||||
* IP (Internet Protocol) including packet forwarding over multiple network
|
||||
interfaces
|
||||
* ICMP (Internet Control Message Protocol) for network maintenance and debugging
|
||||
* IGMP (Internet Group Management Protocol) for multicast traffic management
|
||||
* UDP (User Datagram Protocol) including experimental UDP-lite extensions
|
||||
* TCP (Transmission Control Protocol) with congestion control, RTT estimation
|
||||
and fast recovery/fast retransmit
|
||||
* Specialized raw/native API for enhanced performance
|
||||
* Optional Berkeley-like socket API
|
||||
* DNS (Domain names resolver)
|
||||
* SNMP (Simple Network Management Protocol)
|
||||
* DHCP (Dynamic Host Configuration Protocol)
|
||||
* AUTOIP (for IPv4, conform with RFC 3927)
|
||||
* PPP (Point-to-Point Protocol)
|
||||
* ARP (Address Resolution Protocol) for Ethernet
|
||||
|
||||
LICENSE
|
||||
|
||||
lwIP is freely available under a BSD license.
|
||||
|
||||
DEVELOPMENT
|
||||
|
||||
lwIP has grown into an excellent TCP/IP stack for embedded devices,
|
||||
and developers using the stack often submit bug fixes, improvements,
|
||||
and additions to the stack to further increase its usefulness.
|
||||
|
||||
Development of lwIP is hosted on Savannah, a central point for
|
||||
software development, maintenance and distribution. Everyone can
|
||||
help improve lwIP by use of Savannah's interface, CVS and the
|
||||
mailing list. A core team of developers will commit changes to the
|
||||
CVS source tree.
|
||||
|
||||
The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and
|
||||
contributions (such as platform ports) are in the 'contrib' module.
|
||||
|
||||
See doc/savannah.txt for details on CVS server access for users and
|
||||
developers.
|
||||
|
||||
Last night's CVS tar ball can be downloaded from:
|
||||
http://savannah.gnu.org/cvs.backups/lwip.tar.gz [CHANGED - NEEDS FIXING]
|
||||
|
||||
The current CVS trees are web-browsable:
|
||||
http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/lwip/
|
||||
http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/
|
||||
|
||||
Submit patches and bugs via the lwIP project page:
|
||||
http://savannah.nongnu.org/projects/lwip/
|
||||
|
||||
|
||||
DOCUMENTATION
|
||||
|
||||
The original out-dated homepage of lwIP and Adam Dunkels' papers on
|
||||
lwIP are at the official lwIP home page:
|
||||
http://www.sics.se/~adam/lwip/
|
||||
|
||||
Self documentation of the source code is regularly extracted from the
|
||||
current CVS sources and is available from this web page:
|
||||
http://www.nongnu.org/lwip/
|
||||
|
||||
There is now a constantly growin wiki about lwIP at
|
||||
http://lwip.scribblewiki.com/
|
||||
|
||||
Also, there are mailing lists you can subscribe at
|
||||
http://savannah.nongnu.org/mail/?group=lwip
|
||||
plus searchable archives:
|
||||
http://lists.nongnu.org/archive/html/lwip-users/
|
||||
http://lists.nongnu.org/archive/html/lwip-devel/
|
||||
|
||||
Reading Adam's papers, the files in docs/, browsing the source code
|
||||
documentation and browsing the mailing list archives is a good way to
|
||||
become familiar with the design of lwIP.
|
||||
|
||||
Adam Dunkels <adam@sics.se>
|
||||
Leon Woestenberg <leon.woestenberg@gmx.net>
|
||||
|
||||
6
doc/FILES
Normal file
6
doc/FILES
Normal file
@@ -0,0 +1,6 @@
|
||||
savannah.txt - How to obtain the current development source code.
|
||||
contrib.txt - How to contribute to lwIP as a developer.
|
||||
rawapi.txt - The documentation for the core API of lwIP.
|
||||
Also provides an overview about the other APIs and multithreading.
|
||||
snmp_agent.txt - The documentation for the lwIP SNMP agent.
|
||||
sys_arch.txt - The documentation for a system abstraction layer of lwIP.
|
||||
63
doc/contrib.txt
Normal file
63
doc/contrib.txt
Normal file
@@ -0,0 +1,63 @@
|
||||
1 Introduction
|
||||
|
||||
This document describes some guidelines for people participating
|
||||
in lwIP development.
|
||||
|
||||
2 How to contribute to lwIP
|
||||
|
||||
Here is a short list of suggestions to anybody working with lwIP and
|
||||
trying to contribute bug reports, fixes, enhancements, platform ports etc.
|
||||
First of all as you may already know lwIP is a volunteer project so feedback
|
||||
to fixes or questions might often come late. Hopefully the bug and patch tracking
|
||||
features of Savannah help us not lose users' input.
|
||||
|
||||
2.1 Source code style:
|
||||
|
||||
1. do not use tabs.
|
||||
2. indentation is two spaces per level (i.e. per tab).
|
||||
3. end debug messages with a trailing newline (\n).
|
||||
4. one space between keyword and opening bracket.
|
||||
5. no space between function and opening bracket.
|
||||
6. one space and no newline before opening curly braces of a block.
|
||||
7. closing curly brace on a single line.
|
||||
8. spaces surrounding assignment and comparisons.
|
||||
9. don't initialize static and/or global variables to zero, the compiler takes care of that.
|
||||
10. use current source code style as further reference.
|
||||
|
||||
2.2 Source code documentation style:
|
||||
|
||||
1. JavaDoc compliant and Doxygen compatible.
|
||||
2. Function documentation above functions in .c files, not .h files.
|
||||
(This forces you to synchronize documentation and implementation.)
|
||||
3. Use current documentation style as further reference.
|
||||
|
||||
2.3 Bug reports and patches:
|
||||
|
||||
1. Make sure you are reporting bugs or send patches against the latest
|
||||
sources. (From the latest release and/or the current CVS sources.)
|
||||
2. If you think you found a bug make sure it's not already filed in the
|
||||
bugtracker at Savannah.
|
||||
3. If you have a fix put the patch on Savannah. If it is a patch that affects
|
||||
both core and arch specific stuff please separate them so that the core can
|
||||
be applied separately while leaving the other patch 'open'. The prefered way
|
||||
is to NOT touch archs you can't test and let maintainers take care of them.
|
||||
This is a good way to see if they are used at all - the same goes for unix
|
||||
netifs except tapif.
|
||||
4. Do not file a bug and post a fix to it to the patch area. Either a bug report
|
||||
or a patch will be enough.
|
||||
If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area.
|
||||
5. Trivial patches (compiler warning, indentation and spelling fixes or anything obvious which takes a line or two)
|
||||
can go to the lwip-users list. This is still the fastest way of interaction and the list is not so crowded
|
||||
as to allow for loss of fixes. Putting bugs on Savannah and subsequently closing them is too much an overhead
|
||||
for reporting a compiler warning fix.
|
||||
6. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other
|
||||
trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you
|
||||
change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than
|
||||
if it's not to the point and long :) so the chances for it to be applied are greater.
|
||||
|
||||
2.4 Platform porters:
|
||||
|
||||
1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and
|
||||
you think it could benefit others[1] you might want discuss this on the mailing list. You
|
||||
can also ask for CVS access to submit and maintain your port in the contrib CVS module.
|
||||
|
||||
223
doc/rawapi.txt
223
doc/rawapi.txt
@@ -1,22 +1,61 @@
|
||||
Raw TCP/IP interface for lwIP 0.5
|
||||
Raw TCP/IP interface for lwIP
|
||||
|
||||
Author: Adam Dunkels
|
||||
Authors: Adam Dunkels, Leon Woestenberg, Christiaan Simons
|
||||
|
||||
$Id: rawapi.txt,v 1.1 2002/10/19 12:59:32 likewise Exp $
|
||||
|
||||
lwIP provides two Application Program's Interfaces (APIs) for programs
|
||||
to use for communication with the TCP/IP code: the sequential API
|
||||
(often just called "the API") and the raw TCP/IP interface. This
|
||||
document is intended as a description of the latter. For lwIP versions
|
||||
lower than 0.5, this API was not documented.
|
||||
lwIP provides three Application Program's Interfaces (APIs) for programs
|
||||
to use for communication with the TCP/IP code:
|
||||
* low-level "core" / "callback" or "raw" API.
|
||||
* higher-level "sequential" API.
|
||||
* BSD-style socket API.
|
||||
|
||||
The sequential API provides a way for ordinary, sequential, programs
|
||||
to use the lwIP stack. It is quite similar to the BSD socket API. The
|
||||
model of execution is based on the open-read-write-close
|
||||
model of execution is based on the blocking open-read-write-close
|
||||
paradigm. Since the TCP/IP stack is event based by nature, the TCP/IP
|
||||
code and the application program must reside in different execution
|
||||
contexts (threads).
|
||||
|
||||
The socket API is a compatibility API for existing applications,
|
||||
currently it is built on top of the sequential API. It is meant to
|
||||
provide all functions needed to run socket API applications running
|
||||
on other platforms (e.g. unix / windows etc.). However, due to limitations
|
||||
in the specification of this API, there might be incompatibilities
|
||||
that require small modifications of existing programs.
|
||||
|
||||
** Threading
|
||||
|
||||
lwIP started targeting single-threaded environments. When adding multi-
|
||||
threading support, instead of making the core thread-safe, another
|
||||
approach was chosen: there is one main thread running the lwIP core
|
||||
(also known as the "tcpip_thread"). The raw API may only be used from
|
||||
this thread! Application threads using the sequential- or socket API
|
||||
communicate with this main thread through message passing.
|
||||
|
||||
As such, the list of functions that may be called from
|
||||
other threads or an ISR is very limited! Only functions
|
||||
from these API header files are thread-safe:
|
||||
- api.h
|
||||
- netbuf.h
|
||||
- netdb.h
|
||||
- netifapi.h
|
||||
- sockets.h
|
||||
- sys.h
|
||||
|
||||
Additionaly, memory (de-)allocation functions may be
|
||||
called from multiple threads (not ISR!) with NO_SYS=0
|
||||
since they are protected by SYS_LIGHTWEIGHT_PROT and/or
|
||||
semaphores.
|
||||
|
||||
Only since 1.3.0, if SYS_LIGHTWEIGHT_PROT is set to 1
|
||||
and LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT is set to 1,
|
||||
pbuf_free() may also be called from another thread or
|
||||
an ISR (since only then, mem_free - for PBUF_RAM - may
|
||||
be called from an ISR: otherwise, the HEAP is only
|
||||
protected by semaphores).
|
||||
|
||||
|
||||
** The remainder of this document discusses the "raw" API. **
|
||||
|
||||
The raw TCP/IP interface allows the application program to integrate
|
||||
better with the TCP/IP code. Program execution is event based by
|
||||
having callback functions being called from within the TCP/IP
|
||||
@@ -36,7 +75,6 @@ Both APIs can be used simultaneously by different application
|
||||
programs. In fact, the sequential API is implemented as an application
|
||||
program using the raw TCP/IP interface.
|
||||
|
||||
|
||||
--- Callbacks
|
||||
|
||||
Program execution is driven by callbacks. Each callback is an ordinary
|
||||
@@ -97,6 +135,19 @@ incoming connections or be explicitly connected to another host.
|
||||
listening connection. If so, the memory associated with the pcb
|
||||
passed as an argument to tcp_listen() will not be deallocated.
|
||||
|
||||
- struct tcp_pcb *tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
||||
|
||||
Same as tcp_listen, but limits the number of outstanding connections
|
||||
in the listen queue to the value specified by the backlog argument.
|
||||
To use it, your need to set TCP_LISTEN_BACKLOG=1 in your lwipopts.h.
|
||||
|
||||
- void tcp_accepted(struct tcp_pcb *pcb)
|
||||
|
||||
Inform lwIP that an incoming connection has been accepted. This would
|
||||
usually be called from the accept callback. This allows lwIP to perform
|
||||
housekeeping tasks, such as allowing further incoming connections to be
|
||||
queued in the listen backlog.
|
||||
|
||||
- void tcp_accept(struct tcp_pcb *pcb,
|
||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
|
||||
err_t err))
|
||||
@@ -117,8 +168,9 @@ incoming connections or be explicitly connected to another host.
|
||||
function specified as the fourth argument (the "connected" argument)
|
||||
when the connection is established. If the connection could not be
|
||||
properly established, either because the other host refused the
|
||||
connection or because the other host didn't answer, the "connected"
|
||||
function will be called with an the "err" argument set accordingly.
|
||||
connection or because the other host didn't answer, the "err"
|
||||
callback function of this pcb (registered with tcp_err, see below)
|
||||
will be called.
|
||||
|
||||
The tcp_connect() function can return ERR_MEM if no memory is
|
||||
available for enqueueing the SYN segment. If the SYN indeed was
|
||||
@@ -155,7 +207,7 @@ callback function.
|
||||
|
||||
- void tcp_sent(struct tcp_pcb *pcb,
|
||||
err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
|
||||
u16_t len))
|
||||
u16_t len))
|
||||
|
||||
Specifies the callback function that should be called when data has
|
||||
successfully been received (i.e., acknowledged) by the remote
|
||||
@@ -177,7 +229,10 @@ window.
|
||||
|
||||
Sets the callback function that will be called when new data
|
||||
arrives. The callback function will be passed a NULL pbuf to
|
||||
indicate that the remote host has closed the connection.
|
||||
indicate that the remote host has closed the connection. If
|
||||
there are no errors and the callback function is to return
|
||||
ERR_OK, then it must free the pbuf. Otherwise, it must not
|
||||
free the pbuf so that lwIP core code can store it.
|
||||
|
||||
- void tcp_recved(struct tcp_pcb *pcb, u16_t len)
|
||||
|
||||
@@ -229,7 +284,7 @@ connection are when there is a shortage of memory. The callback
|
||||
function to be called is set using the tcp_err() function.
|
||||
|
||||
- void tcp_err(struct tcp_pcb *pcb, void (* err)(void *arg,
|
||||
err_t err))
|
||||
err_t err))
|
||||
|
||||
The error callback function does not get the pcb passed to it as a
|
||||
parameter since the pcb may already have been deallocated.
|
||||
@@ -274,6 +329,11 @@ level of complexity of UDP, the interface is significantly simpler.
|
||||
Sets the remote end of the pcb. This function does not generate any
|
||||
network traffic, but only set the remote address of the pcb.
|
||||
|
||||
- err_t udp_disconnect(struct udp_pcb *pcb)
|
||||
|
||||
Remove the remote end of the pcb. This function does not generate
|
||||
any network traffic, but only removes the remote address of the pcb.
|
||||
|
||||
- err_t udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
||||
|
||||
Sends the pbuf p. The pbuf is not deallocated.
|
||||
@@ -286,4 +346,133 @@ level of complexity of UDP, the interface is significantly simpler.
|
||||
void *recv_arg)
|
||||
|
||||
Specifies a callback function that should be called when a UDP
|
||||
datagram is received.
|
||||
datagram is received.
|
||||
|
||||
|
||||
--- System initalization
|
||||
|
||||
A truly complete and generic sequence for initializing the lwip stack
|
||||
cannot be given because it depends on the build configuration (lwipopts.h)
|
||||
and additional initializations for your runtime environment (e.g. timers).
|
||||
|
||||
We can give you some idea on how to proceed when using the raw API.
|
||||
We assume a configuration using a single Ethernet netif and the
|
||||
UDP and TCP transport layers, IPv4 and the DHCP client.
|
||||
|
||||
Call these functions in the order of appearance:
|
||||
|
||||
- stats_init()
|
||||
|
||||
Clears the structure where runtime statistics are gathered.
|
||||
|
||||
- sys_init()
|
||||
|
||||
Not of much use since we set the NO_SYS 1 option in lwipopts.h,
|
||||
to be called for easy configuration changes.
|
||||
|
||||
- mem_init()
|
||||
|
||||
Initializes the dynamic memory heap defined by MEM_SIZE.
|
||||
|
||||
- memp_init()
|
||||
|
||||
Initializes the memory pools defined by MEMP_NUM_x.
|
||||
|
||||
- pbuf_init()
|
||||
|
||||
Initializes the pbuf memory pool defined by PBUF_POOL_SIZE.
|
||||
|
||||
- etharp_init()
|
||||
|
||||
Initializes the ARP table and queue.
|
||||
Note: you must call etharp_tmr at a ARP_TMR_INTERVAL (5 seconds) regular interval
|
||||
after this initialization.
|
||||
|
||||
- ip_init()
|
||||
|
||||
Doesn't do much, it should be called to handle future changes.
|
||||
|
||||
- udp_init()
|
||||
|
||||
Clears the UDP PCB list.
|
||||
|
||||
- tcp_init()
|
||||
|
||||
Clears the TCP PCB list and clears some internal TCP timers.
|
||||
Note: you must call tcp_fasttmr() and tcp_slowtmr() at the
|
||||
predefined regular intervals after this initialization.
|
||||
|
||||
- netif_add(struct netif *netif, struct ip_addr *ipaddr,
|
||||
struct ip_addr *netmask, struct ip_addr *gw,
|
||||
void *state, err_t (* init)(struct netif *netif),
|
||||
err_t (* input)(struct pbuf *p, struct netif *netif))
|
||||
|
||||
Adds your network interface to the netif_list. Allocate a struct
|
||||
netif and pass a pointer to this structure as the first argument.
|
||||
Give pointers to cleared ip_addr structures when using DHCP,
|
||||
or fill them with sane numbers otherwise. The state pointer may be NULL.
|
||||
|
||||
The init function pointer must point to a initialization function for
|
||||
your ethernet netif interface. The following code illustrates it's use.
|
||||
|
||||
err_t netif_if_init(struct netif *netif)
|
||||
{
|
||||
u8_t i;
|
||||
|
||||
for(i = 0; i < ETHARP_HWADDR_LEN; i++) netif->hwaddr[i] = some_eth_addr[i];
|
||||
init_my_eth_device();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
For ethernet drivers, the input function pointer must point to the lwip
|
||||
function ethernet_input() declared in "netif/etharp.h". Other drivers
|
||||
must use ip_input() declared in "lwip/ip.h".
|
||||
|
||||
- netif_set_default(struct netif *netif)
|
||||
|
||||
Registers the default network interface.
|
||||
|
||||
- netif_set_up(struct netif *netif)
|
||||
|
||||
When the netif is fully configured this function must be called.
|
||||
|
||||
- dhcp_start(struct netif *netif)
|
||||
|
||||
Creates a new DHCP client for this interface on the first call.
|
||||
Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
|
||||
the predefined regular intervals after starting the client.
|
||||
|
||||
You can peek in the netif->dhcp struct for the actual DHCP status.
|
||||
|
||||
|
||||
--- Optimalization hints
|
||||
|
||||
The first thing you want to optimize is the lwip_standard_checksum()
|
||||
routine from src/core/inet.c. You can override this standard
|
||||
function with the #define LWIP_CHKSUM <your_checksum_routine>.
|
||||
|
||||
There are C examples given in inet.c or you might want to
|
||||
craft an assembly function for this. RFC1071 is a good
|
||||
introduction to this subject.
|
||||
|
||||
Other significant improvements can be made by supplying
|
||||
assembly or inline replacements for htons() and htonl()
|
||||
if you're using a little-endian architecture.
|
||||
#define LWIP_PLATFORM_BYTESWAP 1
|
||||
#define LWIP_PLATFORM_HTONS(x) <your_htons>
|
||||
#define LWIP_PLATFORM_HTONL(x) <your_htonl>
|
||||
|
||||
Check your network interface driver if it reads at
|
||||
a higher speed than the maximum wire-speed. If the
|
||||
hardware isn't serviced frequently and fast enough
|
||||
buffer overflows are likely to occur.
|
||||
|
||||
E.g. when using the cs8900 driver, call cs8900if_service(ethif)
|
||||
as frequently as possible. When using an RTOS let the cs8900 interrupt
|
||||
wake a high priority task that services your driver using a binary
|
||||
semaphore or event flag. Some drivers might allow additional tuning
|
||||
to match your application and network.
|
||||
|
||||
For a production release it is recommended to set LWIP_STATS to 0.
|
||||
Note that speed performance isn't influenced much by simply setting
|
||||
high values to the memory options.
|
||||
|
||||
135
doc/savannah.txt
Normal file
135
doc/savannah.txt
Normal file
@@ -0,0 +1,135 @@
|
||||
Daily Use Guide for using Savannah for lwIP
|
||||
|
||||
Table of Contents:
|
||||
|
||||
1 - Obtaining lwIP from the CVS repository
|
||||
2 - Committers/developers CVS access using SSH (to be written)
|
||||
3 - Merging from DEVEL branch to main trunk (stable branch)
|
||||
4 - How to release lwIP
|
||||
|
||||
|
||||
|
||||
1 Obtaining lwIP from the CVS repository
|
||||
----------------------------------------
|
||||
|
||||
To perform an anonymous CVS checkout of the main trunk (this is where
|
||||
bug fixes and incremental enhancements occur), do this:
|
||||
|
||||
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout lwip
|
||||
|
||||
Or, obtain a stable branch (updated with bug fixes only) as follows:
|
||||
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \
|
||||
-r STABLE-0_7 -d lwip-0.7 lwip
|
||||
|
||||
Or, obtain a specific (fixed) release as follows:
|
||||
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \
|
||||
-r STABLE-0_7_0 -d lwip-0.7.0 lwip
|
||||
|
||||
3 Committers/developers CVS access using SSH
|
||||
--------------------------------------------
|
||||
|
||||
The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption.
|
||||
As such, CVS commits to the server occur through a SSH tunnel for project members.
|
||||
To create a SSH2 key pair in UNIX-like environments, do this:
|
||||
|
||||
ssh-keygen -t dsa
|
||||
|
||||
Under Windows, a recommended SSH client is "PuTTY", freely available with good
|
||||
documentation and a graphic user interface. Use its key generator.
|
||||
|
||||
Now paste the id_dsa.pub contents into your Savannah account public key list. Wait
|
||||
a while so that Savannah can update its configuration (This can take minutes).
|
||||
|
||||
Try to login using SSH:
|
||||
|
||||
ssh -v your_login@cvs.sv.gnu.org
|
||||
|
||||
If it tells you:
|
||||
|
||||
Authenticating with public key "your_key_name"...
|
||||
Server refused to allocate pty
|
||||
|
||||
then you could login; Savannah refuses to give you a shell - which is OK, as we
|
||||
are allowed to use SSH for CVS only. Now, you should be able to do this:
|
||||
|
||||
export CVS_RSH=ssh
|
||||
cvs -z3 -d:ext:your_login@cvs.sv.gnu.org:/sources/lwip co lwip
|
||||
|
||||
after which you can edit your local files with bug fixes or new features and
|
||||
commit them. Make sure you know what you are doing when using CVS to make
|
||||
changes on the repository. If in doubt, ask on the lwip-members mailing list.
|
||||
|
||||
(If SSH asks about authenticity of the host, you can check the key
|
||||
fingerprint against http://savannah.nongnu.org/cvs/?group=lwip)
|
||||
|
||||
|
||||
3 Merging from DEVEL branch to main trunk (stable)
|
||||
--------------------------------------------------
|
||||
|
||||
Merging is a delicate process in CVS and requires the
|
||||
following disciplined steps in order to prevent conflicts
|
||||
in the future. Conflicts can be hard to solve!
|
||||
|
||||
Merging from branch A to branch B requires that the A branch
|
||||
has a tag indicating the previous merger. This tag is called
|
||||
'merged_from_A_to_B'. After merging, the tag is moved in the
|
||||
A branch to remember this merger for future merge actions.
|
||||
|
||||
IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE
|
||||
REPOSITORY, THE TAG MUST BE SET ON THE SOURCE BRANCH OF THE
|
||||
MERGE ACTION (REPLACING EXISTING TAGS WITH THE SAME NAME).
|
||||
|
||||
Merge all changes in DEVEL since our last merge to main:
|
||||
|
||||
In the working copy of the main trunk:
|
||||
cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL
|
||||
|
||||
(This will apply the changes between 'merged_from_DEVEL_to_main'
|
||||
and 'DEVEL' to your work set of files)
|
||||
|
||||
We can now commit the merge result.
|
||||
cvs commit -R -m "Merged from DEVEL to main."
|
||||
|
||||
If this worked out OK, we now move the tag in the DEVEL branch
|
||||
to this merge point, so we can use this point for future merges:
|
||||
|
||||
cvs rtag -F -r DEVEL merged_from_DEVEL_to_main lwip
|
||||
|
||||
4 How to release lwIP
|
||||
---------------------
|
||||
|
||||
First, checkout a clean copy of the branch to be released. Tag this set with
|
||||
tag name "STABLE-0_6_3". (I use release number 0.6.3 throughout this example).
|
||||
|
||||
Login CVS using pserver authentication, then export a clean copy of the
|
||||
tagged tree. Export is similar to a checkout, except that the CVS metadata
|
||||
is not created locally.
|
||||
|
||||
export CVS_RSH=ssh
|
||||
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \
|
||||
-r STABLE-0_6_3 -d lwip-0.6.3 lwip
|
||||
|
||||
Archive this directory using tar, gzip'd, bzip2'd and zip'd.
|
||||
|
||||
tar czvf lwip-0.6.3.tar.gz lwip-0.6.3
|
||||
tar cjvf lwip-0.6.3.tar.bz2 lwip-0.6.3
|
||||
zip -r lwip-0.6.3.zip lwip-0.6.3
|
||||
|
||||
Now, sign the archives with a detached GPG binary signature as follows:
|
||||
|
||||
gpg -b lwip-0.6.3.tar.gz
|
||||
gpg -b lwip-0.6.3.tar.bz2
|
||||
gpg -b lwip-0.6.3.zip
|
||||
|
||||
Upload these files using anonymous FTP:
|
||||
ncftp ftp://savannah.gnu.org/incoming/savannah/lwip
|
||||
|
||||
ncftp>mput *0.6.3.*
|
||||
|
||||
Additionally, you may post a news item on Savannah, like this:
|
||||
|
||||
A new 0.6.3 release is now available here:
|
||||
http://savannah.nongnu.org/files/?group=lwip&highlight=0.6.3
|
||||
|
||||
You will have to submit this via the user News interface, then approve
|
||||
this via the Administrator News interface.
|
||||
181
doc/snmp_agent.txt
Normal file
181
doc/snmp_agent.txt
Normal file
@@ -0,0 +1,181 @@
|
||||
SNMPv1 agent for lwIP
|
||||
|
||||
Author: Christiaan Simons
|
||||
|
||||
This is a brief introduction how to use and configure the SNMP agent.
|
||||
Note the agent uses the raw-API UDP interface so you may also want to
|
||||
read rawapi.txt to gain a better understanding of the SNMP message handling.
|
||||
|
||||
0 Agent Capabilities
|
||||
====================
|
||||
|
||||
SNMPv1 per RFC1157
|
||||
This is an old(er) standard but is still widely supported.
|
||||
For SNMPv2c and v3 have a greater complexity and need many
|
||||
more lines of code. IMHO this breaks the idea of "lightweight IP".
|
||||
|
||||
Note the S in SNMP stands for "Simple". Note that "Simple" is
|
||||
relative. SNMP is simple compared to the complex ISO network
|
||||
management protocols CMIP (Common Management Information Protocol)
|
||||
and CMOT (CMip Over Tcp).
|
||||
|
||||
MIB II per RFC1213
|
||||
The standard lwIP stack management information base.
|
||||
This is a required MIB, so this is always enabled.
|
||||
When builing lwIP without TCP, the mib-2.tcp group is omitted.
|
||||
The groups EGP, CMOT and transmission are disabled by default.
|
||||
|
||||
Most mib-2 objects are not writable except:
|
||||
sysName, sysLocation, sysContact, snmpEnableAuthenTraps.
|
||||
Writing to or changing the ARP and IP address and route
|
||||
tables is not possible.
|
||||
|
||||
Note lwIP has a very limited notion of IP routing. It currently
|
||||
doen't have a route table and doesn't have a notion of the U,G,H flags.
|
||||
Instead lwIP uses the interface list with only one default interface
|
||||
acting as a single gateway interface (G) for the default route.
|
||||
|
||||
The agent returns a "virtual table" with the default route 0.0.0.0
|
||||
for the default interface and network routes (no H) for each
|
||||
network interface in the netif_list.
|
||||
All routes are considered to be up (U).
|
||||
|
||||
Loading additional MIBs
|
||||
MIBs can only be added in compile-time, not in run-time.
|
||||
There is no MIB compiler thus additional MIBs must be hand coded.
|
||||
|
||||
Large SNMP message support
|
||||
The packet decoding and encoding routines are designed
|
||||
to use pbuf-chains. Larger payloads then the minimum
|
||||
SNMP requirement of 484 octets are supported if the
|
||||
PBUF_POOL_SIZE and IP_REASS_BUFSIZE are set to match your
|
||||
local requirement.
|
||||
|
||||
1 Building the Agent
|
||||
====================
|
||||
|
||||
First of all you'll need to add the following define
|
||||
to your local lwipopts.h:
|
||||
|
||||
#define LWIP_SNMP 1
|
||||
|
||||
and add the source files in lwip/src/core/snmp
|
||||
and some snmp headers in lwip/src/include/lwip to your makefile.
|
||||
|
||||
Note you'll might need to adapt you network driver to update
|
||||
the mib2 variables for your interface.
|
||||
|
||||
2 Running the Agent
|
||||
===================
|
||||
|
||||
The following function calls must be made in your program to
|
||||
actually get the SNMP agent running.
|
||||
|
||||
Before starting the agent you should supply pointers
|
||||
to non-volatile memory for sysContact, sysLocation,
|
||||
and snmpEnableAuthenTraps. You can do this by calling
|
||||
|
||||
snmp_set_syscontact()
|
||||
snmp_set_syslocation()
|
||||
snmp_set_snmpenableauthentraps()
|
||||
|
||||
Additionally you may want to set
|
||||
|
||||
snmp_set_sysdescr()
|
||||
snmp_set_sysobjid() (if you have a private MIB)
|
||||
snmp_set_sysname()
|
||||
|
||||
Also before starting the agent you need to setup
|
||||
one or more trap destinations using these calls:
|
||||
|
||||
snmp_trap_dst_enable();
|
||||
snmp_trap_dst_ip_set();
|
||||
|
||||
In the lwIP initialisation sequence call snmp_init() just after
|
||||
the call to udp_init().
|
||||
|
||||
Exactly every 10 msec the SNMP uptime timestamp must be updated with
|
||||
snmp_inc_sysuptime(). You should call this from a timer interrupt
|
||||
or a timer signal handler depending on your runtime environment.
|
||||
|
||||
An alternative way to update the SNMP uptime timestamp is to do a call like
|
||||
snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but call to
|
||||
a lower frequency). Another one is to not call snmp_inc_sysuptime() or
|
||||
snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro.
|
||||
This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside
|
||||
snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only
|
||||
when it's queried (any function which need "sysuptime" have to call
|
||||
snmp_get_sysuptime).
|
||||
|
||||
|
||||
3 Private MIBs
|
||||
==============
|
||||
|
||||
If want to extend the agent with your own private MIB you'll need to
|
||||
add the following define to your local lwipopts.h:
|
||||
|
||||
#define SNMP_PRIVATE_MIB 1
|
||||
|
||||
You must provide the private_mib.h and associated files yourself.
|
||||
Note we don't have a "MIB compiler" that generates C source from a MIB,
|
||||
so you're required to do some serious coding if you enable this!
|
||||
|
||||
Note the lwIP enterprise ID (26381) is assigned to the lwIP project,
|
||||
ALL OBJECT IDENTIFIERS LIVING UNDER THIS ID ARE ASSIGNED BY THE lwIP
|
||||
MAINTAINERS!
|
||||
|
||||
If you need to create your own private MIB you'll need
|
||||
to apply for your own enterprise ID with IANA: http://www.iana.org/numbers.html
|
||||
|
||||
You can set it by passing a struct snmp_obj_id to the agent
|
||||
using snmp_set_sysobjid(&my_object_id), just before snmp_init().
|
||||
|
||||
Note the object identifiers for thes MIB-2 and your private MIB
|
||||
tree must be kept in sorted ascending (lexicographical) order.
|
||||
This to ensure correct getnext operation.
|
||||
|
||||
An example for a private MIB is part of the "minimal Unix" project:
|
||||
contrib/ports/unix/proj/minimal/lwip_prvmib.c
|
||||
|
||||
The next chapter gives a more detailed description of the
|
||||
MIB-2 tree and the optional private MIB.
|
||||
|
||||
4 The Gory Details
|
||||
==================
|
||||
|
||||
4.0 Object identifiers and the MIB tree.
|
||||
|
||||
We have three distinct parts for all object identifiers:
|
||||
|
||||
The prefix
|
||||
.iso.org.dod.internet
|
||||
|
||||
the middle part
|
||||
.mgmt.mib-2.ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress
|
||||
|
||||
and the index part
|
||||
.1.192.168.0.1
|
||||
|
||||
Objects located above the .internet hierarchy aren't supported.
|
||||
Currently only the .mgmt sub-tree is available and
|
||||
when the SNMP_PRIVATE_MIB is enabled the .private tree
|
||||
becomes available too.
|
||||
|
||||
Object identifiers from incoming requests are checked
|
||||
for a matching prefix, middle part and index part
|
||||
or are expanded(*) for GetNext requests with short
|
||||
or inexisting names in the request.
|
||||
(* we call this "expansion" but this also
|
||||
resembles the "auto-completion" operation)
|
||||
|
||||
The middle part is usually located in ROM (const)
|
||||
to preserve precious RAM on small microcontrollers.
|
||||
However RAM location is possible for an dynamically
|
||||
changing private tree.
|
||||
|
||||
The index part is handled by functions which in
|
||||
turn use dynamically allocated index trees from RAM.
|
||||
These trees are updated by e.g. the etharp code
|
||||
when new entries are made or removed form the ARP cache.
|
||||
|
||||
/** @todo more gory details */
|
||||
161
doc/sys_arch.txt
161
doc/sys_arch.txt
@@ -1,9 +1,7 @@
|
||||
sys_arch interface for lwIP 0.5
|
||||
sys_arch interface for lwIP 0.6++
|
||||
|
||||
Author: Adam Dunkels
|
||||
|
||||
$Id: sys_arch.txt,v 1.1 2002/10/19 12:59:33 likewise Exp $
|
||||
|
||||
The operating system emulation layer provides a common interface
|
||||
between the lwIP code and the underlying operating system kernel. The
|
||||
general idea is that porting lwIP to new architectures requires only
|
||||
@@ -18,6 +16,11 @@ functionality. Previous versions of lwIP required the sys_arch to
|
||||
implement timer scheduling as well but as of lwIP 0.5 this is
|
||||
implemented in a higher layer.
|
||||
|
||||
In addition to the source file providing the functionality of sys_arch,
|
||||
the OS emulation layer must provide several header files defining
|
||||
macros used throughout lwip. The files required and the macros they
|
||||
must define are listed below the sys_arch description.
|
||||
|
||||
Semaphores can be either counting or binary - lwIP works with both
|
||||
kinds. Mailboxes are used for message passing and can be implemented
|
||||
either as a queue which allows multiple messages to be posted to a
|
||||
@@ -44,35 +47,35 @@ The following functions must be implemented by the sys_arch:
|
||||
|
||||
- void sys_sem_free(sys_sem_t sem)
|
||||
|
||||
Deallocates a semaphore.
|
||||
Deallocates a semaphore.
|
||||
|
||||
- void sys_sem_signal(sys_sem_t sem)
|
||||
|
||||
Signals a semaphore.
|
||||
|
||||
- u16_t sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)
|
||||
- u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
|
||||
|
||||
Blocks the thread while waiting for the semaphore to be
|
||||
signaled. If the "timeout" argument is non-zero, the thread should
|
||||
only be blocked for the specified time (measured in
|
||||
milliseconds).
|
||||
milliseconds). If the "timeout" argument is zero, the thread should be
|
||||
blocked until the semaphore is signalled.
|
||||
|
||||
If the timeout argument is non-zero, the return value is the amount
|
||||
of time spent waiting for the semaphore to be signaled. If the
|
||||
semaphore wasn't signaled within the specified time, the return
|
||||
value is zero. If the thread didn't have to wait for the semaphore
|
||||
(i.e., it was already signaled), care must be taken to ensure that
|
||||
the function does not return a zero value since this is used to
|
||||
indicate that a timeout occured. A suitable way to implement this is
|
||||
to check if the time spent waiting is zero and if so, the value 1 is
|
||||
returned.
|
||||
If the timeout argument is non-zero, the return value is the number of
|
||||
milliseconds spent waiting for the semaphore to be signaled. If the
|
||||
semaphore wasn't signaled within the specified time, the return value is
|
||||
SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
|
||||
(i.e., it was already signaled), the function may return zero.
|
||||
|
||||
Notice that lwIP implements a function with a similar name,
|
||||
sys_sem_wait(), that uses the sys_arch_sem_wait() function.
|
||||
|
||||
- sys_mbox_t sys_mbox_new(void)
|
||||
- sys_mbox_t sys_mbox_new(int size)
|
||||
|
||||
Creates an empty mailbox.
|
||||
Creates an empty mailbox for maximum "size" elements. Elements stored
|
||||
in mailboxes are pointers. You have to define macros "_MBOX_SIZE"
|
||||
in your lwipopts.h, or ignore this parameter in your implementation
|
||||
and use a default size.
|
||||
|
||||
- void sys_mbox_free(sys_mbox_t mbox)
|
||||
|
||||
@@ -82,24 +85,43 @@ The following functions must be implemented by the sys_arch:
|
||||
|
||||
- void sys_mbox_post(sys_mbox_t mbox, void *msg)
|
||||
|
||||
Posts the "msg" to the mailbox.
|
||||
Posts the "msg" to the mailbox. This function have to block until
|
||||
the "msg" is really posted.
|
||||
|
||||
- u16_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u16_t timeout)
|
||||
- err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg)
|
||||
|
||||
Try to post the "msg" to the mailbox. Returns ERR_MEM if this one
|
||||
is full, else, ERR_OK if the "msg" is posted.
|
||||
|
||||
- u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
|
||||
|
||||
Blocks the thread until a message arrives in the mailbox, but does
|
||||
not block the thread longer than "timeout" milliseconds (similar to
|
||||
the sys_arch_sem_wait() function). The "msg" argument is a result
|
||||
the sys_arch_sem_wait() function). If "timeout" is 0, the thread should
|
||||
be blocked until a message arrives. The "msg" argument is a result
|
||||
parameter that is set by the function (i.e., by doing "*msg =
|
||||
ptr"). The "msg" parameter maybe NULL to indicate that the message
|
||||
should be dropped.
|
||||
|
||||
The return values are the same as for the sys_arch_sem_wait()
|
||||
function and the function must not return zero even if a message was
|
||||
present in the mailbox and the time spent waiting was zero
|
||||
milliseconds.
|
||||
The return values are the same as for the sys_arch_sem_wait() function:
|
||||
Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
|
||||
timeout.
|
||||
|
||||
Note that a function with a similar name, sys_mbox_fetch(), is
|
||||
implemented by lwIP.
|
||||
|
||||
- u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg)
|
||||
|
||||
This is similar to sys_arch_mbox_fetch, however if a message is not
|
||||
present in the mailbox, it immediately returns with the code
|
||||
SYS_MBOX_EMPTY. On success 0 is returned.
|
||||
|
||||
To allow for efficient implementations, this can be defined as a
|
||||
function-like macro in sys_arch.h instead of a normal function. For
|
||||
example, a naive implementation could be:
|
||||
#define sys_arch_mbox_tryfetch(mbox,msg) \
|
||||
sys_arch_mbox_fetch(mbox,msg,1)
|
||||
although this would introduce unnecessary delays.
|
||||
|
||||
- struct sys_timeouts *sys_arch_timeouts(void)
|
||||
|
||||
@@ -109,7 +131,7 @@ The following functions must be implemented by the sys_arch:
|
||||
pointer to a linked list of timeouts. This function is called by
|
||||
the lwIP timeout scheduler and must not return a NULL value.
|
||||
|
||||
In a single threadd sys_arch implementation, this function will
|
||||
In a single thread sys_arch implementation, this function will
|
||||
simply return a pointer to a global sys_timeouts variable stored in
|
||||
the sys_arch module.
|
||||
|
||||
@@ -117,9 +139,90 @@ If threads are supported by the underlying operating system and if
|
||||
such functionality is needed in lwIP, the following function will have
|
||||
to be implemented as well:
|
||||
|
||||
- void sys_thread_new(void (* thread)(void *arg), void *arg)
|
||||
- sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio)
|
||||
|
||||
Starts a new thread that will begin its execution in the function
|
||||
"thread()". The "arg" argument will be passed as an argument to the
|
||||
thread() function.
|
||||
Starts a new thread named "name" with priority "prio" that will begin its
|
||||
execution in the function "thread()". The "arg" argument will be passed as an
|
||||
argument to the thread() function. The stack size to used for this thread is
|
||||
the "stacksize" parameter. The id of the new thread is returned. Both the id
|
||||
and the priority are system dependent.
|
||||
|
||||
- sys_prot_t sys_arch_protect(void)
|
||||
|
||||
This optional function does a "fast" critical region protection and returns
|
||||
the previous protection level. This function is only called during very short
|
||||
critical regions. An embedded system which supports ISR-based drivers might
|
||||
want to implement this function by disabling interrupts. Task-based systems
|
||||
might want to implement this by using a mutex or disabling tasking. This
|
||||
function should support recursive calls from the same task or interrupt. In
|
||||
other words, sys_arch_protect() could be called while already protected. In
|
||||
that case the return value indicates that it is already protected.
|
||||
|
||||
sys_arch_protect() is only required if your port is supporting an operating
|
||||
system.
|
||||
|
||||
- void sys_arch_unprotect(sys_prot_t pval)
|
||||
|
||||
This optional function does a "fast" set of critical region protection to the
|
||||
value specified by pval. See the documentation for sys_arch_protect() for
|
||||
more information. This function is only required if your port is supporting
|
||||
an operating system.
|
||||
|
||||
Note:
|
||||
|
||||
Be carefull with using mem_malloc() in sys_arch. When malloc() refers to
|
||||
mem_malloc() you can run into a circular function call problem. In mem.c
|
||||
mem_init() tries to allcate a semaphore using mem_malloc, which of course
|
||||
can't be performed when sys_arch uses mem_malloc.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Additional files required for the "OS support" emulation layer:
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
cc.h - Architecture environment, some compiler specific, some
|
||||
environment specific (probably should move env stuff
|
||||
to sys_arch.h.)
|
||||
|
||||
Typedefs for the types used by lwip -
|
||||
u8_t, s8_t, u16_t, s16_t, u32_t, s32_t, mem_ptr_t
|
||||
|
||||
Compiler hints for packing lwip's structures -
|
||||
PACK_STRUCT_FIELD(x)
|
||||
PACK_STRUCT_STRUCT
|
||||
PACK_STRUCT_BEGIN
|
||||
PACK_STRUCT_END
|
||||
|
||||
Platform specific diagnostic output -
|
||||
LWIP_PLATFORM_DIAG(x) - non-fatal, print a message.
|
||||
LWIP_PLATFORM_ASSERT(x) - fatal, print message and abandon execution.
|
||||
Portability defines for printf formatters:
|
||||
U16_F, S16_F, X16_F, U32_F, S32_F, X32_F, SZT_F
|
||||
|
||||
"lightweight" synchronization mechanisms -
|
||||
SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable.
|
||||
SYS_ARCH_PROTECT(x) - enter protection mode.
|
||||
SYS_ARCH_UNPROTECT(x) - leave protection mode.
|
||||
|
||||
If the compiler does not provide memset() this file must include a
|
||||
definition of it, or include a file which defines it.
|
||||
|
||||
This file must either include a system-local <errno.h> which defines
|
||||
the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO
|
||||
to make lwip/arch.h define the codes which are used throughout.
|
||||
|
||||
|
||||
perf.h - Architecture specific performance measurement.
|
||||
Measurement calls made throughout lwip, these can be defined to nothing.
|
||||
PERF_START - start measuring something.
|
||||
PERF_STOP(x) - stop measuring something, and record the result.
|
||||
|
||||
sys_arch.h - Tied to sys_arch.c
|
||||
|
||||
Arch dependent types for the following objects:
|
||||
sys_sem_t, sys_mbox_t, sys_thread_t,
|
||||
And, optionally:
|
||||
sys_prot_t
|
||||
|
||||
Defines to set vars of sys_mbox_t and sys_sem_t to NULL.
|
||||
SYS_MBOX_NULL NULL
|
||||
SYS_SEM_NULL NULL
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
# Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the Institute nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# This file is part of the lwIP TCP/IP stack.
|
||||
#
|
||||
# Author: Adam Dunkels <adam@sics.se>
|
||||
#
|
||||
# $Id: Makefile,v 1.1 2002/10/19 12:59:33 likewise Exp $
|
||||
|
||||
CCDEP=gcc
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -DIPv4 -Os -fpack-struct
|
||||
LWIPARCH=unix
|
||||
ARFLAGS=rs
|
||||
LWIPDIR=../../src
|
||||
|
||||
CFLAGS:=$(CFLAGS) \
|
||||
-I$(LWIPDIR)/include -I$(LWIPDIR)/arch/$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
||||
-Iapps -I.
|
||||
|
||||
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
||||
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
|
||||
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \
|
||||
$(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_input.c \
|
||||
$(LWIPDIR)/core/tcp_output.c $(LWIPDIR)/core/udp.c
|
||||
CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \
|
||||
$(LWIPDIR)/core/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c
|
||||
|
||||
# NETIFFILES: Files implementing various generic network interface functions.'
|
||||
NETIFFILES=$(LWIPDIR)/netif/etharp.c mintapif.c
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
# APPFILES
|
||||
APPFILES=echo.c
|
||||
|
||||
LWIPLIB=liblwip4.a
|
||||
APPLIB=liblwipapps.a
|
||||
APPOBJS=$(notdir $(APPFILES:.c=.o))
|
||||
|
||||
%.o:
|
||||
$(CC) $(CFLAGS) -c $(<:.o=.c)
|
||||
|
||||
all ipv4 compile: minimal
|
||||
.PHONY: all
|
||||
|
||||
clean:
|
||||
rm -f *.o $(LWIPLIB) $(APPLIB) minimal .depend* *.core core
|
||||
|
||||
depend dep: .depend
|
||||
|
||||
include .depend
|
||||
|
||||
$(APPLIB): $(APPOBJS)
|
||||
$(AR) $(ARFLAGS) $(APPLIB) $?
|
||||
|
||||
$(LWIPLIB): $(LWIPOBJS)
|
||||
$(AR) $(ARFLAGS) $(LWIPLIB) $?
|
||||
|
||||
.depend: main.c $(LWIPFILES) $(APPFILES)
|
||||
$(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend
|
||||
|
||||
minimal: .depend $(LWIPLIB) $(APPLIB) main.o $(APPFILES)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o minimal main.o $(APPLIB) $(LWIPLIB)
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
This is an example of a very minimal lwIP project. It runs in a single
|
||||
thread and runs a single example application - an echo server. The
|
||||
echo application is implemented using the raw API.
|
||||
@@ -1,220 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
struct echo_state {
|
||||
struct pbuf *p;
|
||||
u8_t failed;
|
||||
#define FAILED_MAX 8
|
||||
};
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
echo_err(void *arg, err_t err)
|
||||
{
|
||||
struct echo_state *es = arg;
|
||||
|
||||
if(arg != NULL) {
|
||||
pbuf_free(es->p);
|
||||
mem_free(arg);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
close_conn(struct tcp_pcb *pcb, struct echo_state *es)
|
||||
{
|
||||
tcp_arg(pcb, NULL);
|
||||
#if 0
|
||||
tcp_sent(pcb, NULL);
|
||||
tcp_recv(pcb, NULL);
|
||||
#endif /* 0 */
|
||||
if(es != NULL) {
|
||||
pbuf_free(es->p);
|
||||
mem_free(es);
|
||||
}
|
||||
tcp_close(pcb);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
send_buf(struct tcp_pcb *pcb, struct echo_state *es)
|
||||
{
|
||||
struct pbuf *q;
|
||||
|
||||
do {
|
||||
q = es->p;
|
||||
es->p = pbuf_dechain(q);
|
||||
if(tcp_write(pcb, q->payload, q->len, 1) == ERR_MEM) {
|
||||
pbuf_chain(q, es->p);
|
||||
es->p = q;
|
||||
return;
|
||||
}
|
||||
tcp_recved(pcb, q->len);
|
||||
pbuf_free(q);
|
||||
} while(es->p != NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
echo_poll(void *arg, struct tcp_pcb *pcb)
|
||||
{
|
||||
struct echo_state *es;
|
||||
|
||||
if(arg == NULL) {
|
||||
return tcp_close(pcb);
|
||||
}
|
||||
|
||||
es = arg;
|
||||
|
||||
if(es->failed >= FAILED_MAX) {
|
||||
close_conn(pcb, es);
|
||||
tcp_abort(pcb);
|
||||
return ERR_ABRT;
|
||||
}
|
||||
|
||||
if(es->p != NULL) {
|
||||
++es->failed;
|
||||
send_buf(pcb, es);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
echo_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||
{
|
||||
struct echo_state *es;
|
||||
|
||||
es = arg;
|
||||
|
||||
if(es != NULL && es->p != NULL) {
|
||||
send_buf(pcb, es);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
echo_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
{
|
||||
struct echo_state *es;
|
||||
|
||||
es = arg;
|
||||
|
||||
if(p == NULL) {
|
||||
close_conn(pcb, es);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
if(es->p != NULL) {
|
||||
pbuf_chain(es->p, p);
|
||||
} else {
|
||||
es->p = p;
|
||||
}
|
||||
|
||||
send_buf(pcb, es);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
echo_accept(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
{
|
||||
struct echo_state *es;
|
||||
|
||||
tcp_setprio(pcb, TCP_PRIO_MIN);
|
||||
|
||||
/* Allocate memory for the structure that holds the state of the
|
||||
connection. */
|
||||
es = mem_malloc(sizeof(struct echo_state));
|
||||
|
||||
if(es == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
/* Initialize the structure. */
|
||||
es->p = NULL;
|
||||
es->failed = 0;
|
||||
|
||||
/* Tell TCP that this is the structure we wish to be passed for our
|
||||
callbacks. */
|
||||
tcp_arg(pcb, es);
|
||||
|
||||
/* Tell TCP that we wish to be informed of incoming data by a call
|
||||
to the http_recv() function. */
|
||||
#if 0
|
||||
tcp_recv(pcb, echo_recv);
|
||||
|
||||
tcp_err(pcb, echo_err);
|
||||
#endif /* 0 */
|
||||
|
||||
tcp_poll(pcb, echo_poll, 2);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
echo_init(void)
|
||||
{
|
||||
struct tcp_pcb *pcb;
|
||||
|
||||
pcb = tcp_new();
|
||||
tcp_bind(pcb, IP_ADDR_ANY, 7);
|
||||
pcb = tcp_listen(pcb);
|
||||
#if 0
|
||||
tcp_accept(pcb, echo_accept);
|
||||
#endif /* 0 */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
err_t
|
||||
lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
|
||||
enum lwip_event ev, struct pbuf *p,
|
||||
u16_t size, err_t err)
|
||||
{
|
||||
switch(ev) {
|
||||
case LWIP_EVENT_ACCEPT:
|
||||
return echo_accept(arg, pcb, err);
|
||||
case LWIP_EVENT_SENT:
|
||||
return echo_sent(arg, pcb, size);
|
||||
case LWIP_EVENT_RECV:
|
||||
return echo_recv(arg, pcb, p, err);
|
||||
case LWIP_EVENT_ERR:
|
||||
echo_err(arg, err);
|
||||
break;
|
||||
case LWIP_EVENT_POLL:
|
||||
return echo_poll(arg, pcb);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#define NO_SYS 1
|
||||
#define LWIP_EVENT_API 1
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 2
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#define MEM_SIZE 1000
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 8
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 4
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 2
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 8
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 8
|
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */
|
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
|
||||
#define MEMP_NUM_NETBUF 0
|
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */
|
||||
#define MEMP_NUM_NETCONN 0
|
||||
/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
|
||||
communication between the TCP/IP stack and the sequential
|
||||
programs. */
|
||||
#define MEMP_NUM_API_MSG 0
|
||||
/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in
|
||||
src/api/tcpip.c. */
|
||||
#define MEMP_NUM_TCPIP_MSG 0
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 0
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#define PBUF_POOL_SIZE 8
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 128
|
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. */
|
||||
#define PBUF_LINK_HLEN 16
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 0
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS 128
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#define TCP_SND_BUF 256
|
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */
|
||||
#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND 512
|
||||
|
||||
/* Maximum number of retransmissions of data segments. */
|
||||
#define TCP_MAXRTX 12
|
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */
|
||||
#define TCP_SYNMAXRTX 4
|
||||
|
||||
/* ---------- ARP options ---------- */
|
||||
#define ARP_TABLE_SIZE 10
|
||||
|
||||
/* ---------- IP options ---------- */
|
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP
|
||||
on a device with only one network interface, define this to 0. */
|
||||
#define IP_FORWARD 0
|
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */
|
||||
#define IP_OPTIONS 1
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define ICMP_TTL 255
|
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
||||
turning this on does currently not work. */
|
||||
#define LWIP_DHCP 0
|
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 0
|
||||
#define UDP_TTL 255
|
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
/*#define STATS*/
|
||||
|
||||
#ifdef STATS
|
||||
#define LINK_STATS
|
||||
#define IP_STATS
|
||||
#define ICMP_STATS
|
||||
#define UDP_STATS
|
||||
#define TCP_STATS
|
||||
#define MEM_STATS
|
||||
#define MEMP_STATS
|
||||
#define PBUF_STATS
|
||||
#define SYS_STATS
|
||||
#endif /* STATS */
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "mintapif.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct ip_addr ipaddr, netmask, gw;
|
||||
struct netif *netif;
|
||||
|
||||
#ifdef PERF
|
||||
perf_init("/tmp/minimal.perf");
|
||||
#endif /* PERF */
|
||||
#ifdef STATS
|
||||
stats_init();
|
||||
#endif /* STATS */
|
||||
|
||||
mem_init();
|
||||
memp_init();
|
||||
pbuf_init();
|
||||
netif_init();
|
||||
ip_init();
|
||||
udp_init();
|
||||
tcp_init();
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
IP4_ADDR(&gw, 192,168,0,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,0,2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
netif = netif_add(&ipaddr, &netmask, &gw, mintapif_init, ip_input);
|
||||
|
||||
netif_set_default(netif);
|
||||
|
||||
echo_init();
|
||||
|
||||
printf("Applications started.\n");
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
if(mintapif_wait(netif, 100) == MINTAPIF_TIMEOUT) {
|
||||
tcp_tmr();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,354 +0,0 @@
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef linux
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#define DEVTAP "/dev/net/tun"
|
||||
#else /* linux */
|
||||
#define DEVTAP "/dev/tap0"
|
||||
#endif /* linux */
|
||||
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#include "mintapif.h"
|
||||
|
||||
/* Define those to better describe your network interface. */
|
||||
#define IFNAME0 'e'
|
||||
#define IFNAME1 't'
|
||||
|
||||
struct mintapif {
|
||||
struct eth_addr *ethaddr;
|
||||
/* Add whatever per-interface state that is needed here. */
|
||||
u32_t lasttime;
|
||||
int fd;
|
||||
};
|
||||
|
||||
static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
|
||||
|
||||
/* Forward declarations. */
|
||||
static void mintapif_input(struct netif *netif);
|
||||
static err_t mintapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
struct mintapif *mintapif;
|
||||
char buf[1024];
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
/* Obtain MAC address from network interface. */
|
||||
mintapif->ethaddr->addr[0] = 1;
|
||||
mintapif->ethaddr->addr[1] = 2;
|
||||
mintapif->ethaddr->addr[2] = 3;
|
||||
mintapif->ethaddr->addr[3] = 4;
|
||||
mintapif->ethaddr->addr[4] = 5;
|
||||
mintapif->ethaddr->addr[5] = 6;
|
||||
|
||||
/* Do whatever else is needed to initialize interface. */
|
||||
|
||||
mintapif->fd = open(DEVTAP, O_RDWR);
|
||||
if(mintapif->fd == -1) {
|
||||
perror("tapif: tapif_init: open");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef linux
|
||||
{
|
||||
struct ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
|
||||
if (ioctl(mintapif->fd, TUNSETIFF, (void *) &ifr) < 0) {
|
||||
perror(buf);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif /* Linux */
|
||||
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet %d.%d.%d.%d",
|
||||
ip4_addr1(&(netif->gw)),
|
||||
ip4_addr2(&(netif->gw)),
|
||||
ip4_addr3(&(netif->gw)),
|
||||
ip4_addr4(&(netif->gw)));
|
||||
|
||||
system(buf);
|
||||
|
||||
mintapif->lasttime = 0;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* low_level_output():
|
||||
*
|
||||
* Should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
* might be chained.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
low_level_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct mintapif *mintapif;
|
||||
struct pbuf *q;
|
||||
char buf[1500];
|
||||
char *bufptr;
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
/* initiate transfer(); */
|
||||
|
||||
bufptr = &buf[0];
|
||||
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Send the data from the pbuf to the interface, one pbuf at a
|
||||
time. The size of the data in each pbuf is kept in the ->len
|
||||
variable. */
|
||||
/* send data from(q->payload, q->len); */
|
||||
bcopy(q->payload, bufptr, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
|
||||
/* signal that packet should be sent(); */
|
||||
if(write(mintapif->fd, buf, p->tot_len) == -1) {
|
||||
perror("tapif: write");
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* low_level_input():
|
||||
*
|
||||
* Should allocate a pbuf and transfer the bytes of the incoming
|
||||
* packet from the interface into the pbuf.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct pbuf *
|
||||
low_level_input(struct mintapif *mintapif)
|
||||
{
|
||||
struct pbuf *p, *q;
|
||||
u16_t len;
|
||||
char buf[1500];
|
||||
char *bufptr;
|
||||
|
||||
/* Obtain the size of the packet and put it into the "len"
|
||||
variable. */
|
||||
len = read(mintapif->fd, buf, sizeof(buf));
|
||||
|
||||
/* if(((double)rand()/(double)RAND_MAX) < 0.1) {
|
||||
printf("drop\n");
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
|
||||
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
|
||||
|
||||
if(p != NULL) {
|
||||
/* We iterate over the pbuf chain until we have read the entire
|
||||
packet into the pbuf. */
|
||||
bufptr = &buf[0];
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Read enough bytes to fill this pbuf in the chain. The
|
||||
avaliable data in the pbuf is given by the q->len
|
||||
variable. */
|
||||
/* read data into(q->payload, q->len); */
|
||||
bcopy(bufptr, q->payload, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
/* acknowledge that packet has been read(); */
|
||||
} else {
|
||||
/* drop packet(); */
|
||||
printf("Could not allocate pbufs\n");
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* mintapif_output():
|
||||
*
|
||||
* This function is called by the TCP/IP stack when an IP packet
|
||||
* should be sent. It calls the function called low_level_output() to
|
||||
* do the actuall transmission of the packet.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
mintapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
if(p != NULL) {
|
||||
return low_level_output(netif, p);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* mintapif_input():
|
||||
*
|
||||
* This function should be called when a packet is ready to be read
|
||||
* from the interface. It uses the function low_level_input() that
|
||||
* should handle the actual reception of bytes from the network
|
||||
* interface.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
mintapif_input(struct netif *netif)
|
||||
{
|
||||
struct mintapif *mintapif;
|
||||
struct eth_hdr *ethhdr;
|
||||
struct pbuf *p, *q;
|
||||
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
p = low_level_input(mintapif);
|
||||
|
||||
if(p != NULL) {
|
||||
|
||||
#ifdef LINK_STATS
|
||||
stats.link.recv++;
|
||||
#endif /* LINK_STATS */
|
||||
|
||||
ethhdr = p->payload;
|
||||
|
||||
q = NULL;
|
||||
switch(htons(ethhdr->type)) {
|
||||
case ETHTYPE_IP:
|
||||
q = etharp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
q = etharp_arp_input(netif, mintapif->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
if(q != NULL) {
|
||||
low_level_output(netif, q);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* mintapif_init():
|
||||
*
|
||||
* Should be called at the beginning of the program to set up the
|
||||
* network interface. It calls the function low_level_init() to do the
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
mintapif_init(struct netif *netif)
|
||||
{
|
||||
struct mintapif *mintapif;
|
||||
|
||||
mintapif = mem_malloc(sizeof(struct mintapif));
|
||||
netif->state = mintapif;
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
netif->output = mintapif_output;
|
||||
netif->linkoutput = low_level_output;
|
||||
|
||||
mintapif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
||||
|
||||
low_level_init(netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
enum mintapif_signal
|
||||
mintapif_wait(struct netif *netif, u16_t time)
|
||||
{
|
||||
fd_set fdset;
|
||||
struct timeval tv, now;
|
||||
struct timezone tz;
|
||||
int ret;
|
||||
struct mintapif *mintapif;
|
||||
|
||||
mintapif = netif->state;
|
||||
|
||||
while(1) {
|
||||
|
||||
if(mintapif->lasttime >= (u32_t)time * 1000) {
|
||||
mintapif->lasttime = 0;
|
||||
return MINTAPIF_TIMEOUT;
|
||||
}
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = (u32_t)time * 1000 - mintapif->lasttime;
|
||||
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(mintapif->fd, &fdset);
|
||||
|
||||
gettimeofday(&now, &tz);
|
||||
ret = select(mintapif->fd + 1, &fdset, NULL, NULL, &tv);
|
||||
if(ret == 0) {
|
||||
mintapif->lasttime = 0;
|
||||
return MINTAPIF_TIMEOUT;
|
||||
}
|
||||
gettimeofday(&tv, &tz);
|
||||
mintapif->lasttime += (tv.tv_sec - now.tv_sec) * 1000000 + (tv.tv_usec - now.tv_usec);
|
||||
|
||||
mintapif_input(netif);
|
||||
}
|
||||
|
||||
return MINTAPIF_PACKET;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __MINTAPIF_H__
|
||||
#define __MINTAPIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
enum mintapif_signal {
|
||||
MINTAPIF_TIMEOUT,
|
||||
MINTAPIF_PACKET
|
||||
};
|
||||
|
||||
void mintapif_init(struct netif *netif);
|
||||
enum mintapif_signal mintapif_wait(struct netif *netif, u16_t time);
|
||||
|
||||
#endif /* __MINTAPIF_H__ */
|
||||
@@ -1,111 +0,0 @@
|
||||
# Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the Institute nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# This file is part of the lwIP TCP/IP stack.
|
||||
#
|
||||
# Author: Adam Dunkels <adam@sics.se>
|
||||
#
|
||||
# $Id: Makefile,v 1.1 2002/10/19 12:59:37 likewise Exp $
|
||||
|
||||
CCDEP=gcc
|
||||
CC=gcc
|
||||
CFLAGS=-g -Wall -DIPv4 -DLWIP_DEBUG -pedantic
|
||||
LDFLAGS=-lpcap
|
||||
LWIPARCH=unix
|
||||
ARFLAGS=rs
|
||||
LWIPDIR=../../src
|
||||
|
||||
CFLAGS:=$(CFLAGS) \
|
||||
-I$(LWIPDIR)/include -I$(LWIPDIR)/arch/$(LWIPARCH)/include -I$(LWIPDIR)/include/ipv4 \
|
||||
-Iapps -I.
|
||||
|
||||
# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
|
||||
COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
|
||||
$(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \
|
||||
$(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_input.c \
|
||||
$(LWIPDIR)/core/tcp_output.c $(LWIPDIR)/core/udp.c
|
||||
CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \
|
||||
$(LWIPDIR)/core/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c
|
||||
|
||||
|
||||
# APIFILES: The files which implement the sequential and socket APIs.
|
||||
APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
|
||||
$(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c
|
||||
|
||||
# NETIFFILES: Files implementing various generic network interface functions.'
|
||||
NETIFFILES=$(LWIPDIR)/netif/loopif.c \
|
||||
$(LWIPDIR)/netif/tcpdump.c $(LWIPDIR)/netif/etharp.c
|
||||
|
||||
# ARCHFILES: Archiecture specific files.
|
||||
ARCHFILES=$(wildcard $(LWIPDIR)/arch/$(LWIPARCH)/*.c $(LWIPDIR)/arch/$(LWIPARCH)/netif/*.c)
|
||||
|
||||
# APPFILES: Applications.
|
||||
APPFILES=apps/fs.c apps/httpd.c \
|
||||
apps/udpecho.c apps/tcpecho.c \
|
||||
apps/shell.c
|
||||
|
||||
# LWIPFILES: All the above.
|
||||
LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
|
||||
LWIPFILESW=$(wildcard $(LWIPFILES))
|
||||
LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
|
||||
|
||||
LWIPLIB=liblwip4.a
|
||||
APPLIB=liblwipapps.a
|
||||
APPOBJS=$(notdir $(APPFILES:.c=.o))
|
||||
|
||||
%.o:
|
||||
$(CC) $(CFLAGS) -c $(<:.o=.c)
|
||||
|
||||
all ipv4 compile: simhost simnode simrouter
|
||||
.PHONY: all
|
||||
|
||||
clean:
|
||||
rm -f *.o $(LWIPLIB) $(APPLIB) simhost simnode simrouter *.s .depend* *.core core
|
||||
|
||||
depend dep: .depend
|
||||
|
||||
include .depend
|
||||
|
||||
$(APPLIB): $(APPOBJS)
|
||||
$(AR) $(ARFLAGS) $(APPLIB) $?
|
||||
|
||||
$(LWIPLIB): $(LWIPOBJS)
|
||||
$(AR) $(ARFLAGS) $(LWIPLIB) $?
|
||||
|
||||
.depend: simhost.c simnode.c simrouter.c $(LWIPFILES) $(APPFILES)
|
||||
$(CCDEP) $(CFLAGS) -MM $^ > .depend || rm -f .depend
|
||||
|
||||
simhost: .depend $(LWIPLIB) $(APPLIB) simhost.o $(APPFILES)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -pthread -o simhost simhost.o $(APPLIB) $(LWIPLIB)
|
||||
|
||||
simrouter: .depend $(LWIPLIB) $(APPLIB) simrouter.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -pthread -o simrouter simrouter.o $(APPLIB) $(LWIPLIB)
|
||||
|
||||
simnode: .depend $(LWIPLIB) $(APPLIB) simnode.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -pthread -o simnode simnode.o $(APPLIB) $(LWIPLIB)
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
This directory contains an example of how a project using lwIP might
|
||||
look. It is also the development platform of lwIP, since it can be run
|
||||
as a user process under FreeBSD or Linux. There are also a number of
|
||||
example applications (including a simple web server) in the apps/
|
||||
directory.
|
||||
|
||||
Some short instructions on how to build and run lwIP on a FreeBSD or
|
||||
Linux host. For FreeBSD, the tap interface must be enabled in the
|
||||
kernel configuration and the kernel must be recompiled. The tap
|
||||
interface is enabled by adding the line "pseudo-device tap" in the
|
||||
kernel configuration. See Chapter 9 in the FreeBSD handbook for
|
||||
instructions on how to build a custom FreeBSD kernel.
|
||||
|
||||
* Compile the code. This must be done by using GNU Make. Under
|
||||
FreeBSD, GNU Make can be found in the ports collection under
|
||||
/usr/ports/devel/gmake (type "make install distclean" to
|
||||
install). Under Linux, GNU Make is the default "make".
|
||||
|
||||
> gmake (FreeBSD)
|
||||
|
||||
> make (Linux)
|
||||
|
||||
* The compilation process produces the executable file "simhost". To
|
||||
run this, you have to be root.
|
||||
|
||||
> su (Type password for the root account)
|
||||
# ./simhost
|
||||
|
||||
* The lwIP TCP/IP stack is now running with IP address
|
||||
192.168.0.2. Some things that you can try:
|
||||
|
||||
To see the packets that are going to and from the lwIP stack, run
|
||||
tcpdump:
|
||||
|
||||
# tcpdump -l -n -i tap0
|
||||
|
||||
You can ping lwIP:
|
||||
|
||||
> ping 192.168.0.2
|
||||
|
||||
For a telnet shell, run:
|
||||
|
||||
> telnet 192.168.0.2
|
||||
|
||||
Finally, "simhost" also includes a simple web server; the URL is
|
||||
of course http://192.168.0.2/.
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#include "lwip/def.h"
|
||||
#include "fs.h"
|
||||
#include "fsdata.h"
|
||||
#include "fsdata.c"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
fs_open(char *name, struct fs_file *file)
|
||||
{
|
||||
struct fsdata_file_noconst *f;
|
||||
|
||||
for(f = (struct fsdata_file_noconst *)FS_ROOT; f != NULL; f = (struct fsdata_file_noconst *)f->next) {
|
||||
if(!strcmp(name, f->name)) {
|
||||
file->data = f->data;
|
||||
file->len = f->len;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __FS_H__
|
||||
#define __FS_H__
|
||||
|
||||
struct fs_file {
|
||||
char *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
/* file must be allocated by caller and will be filled in
|
||||
by the function. */
|
||||
int fs_open(char *name, struct fs_file *file);
|
||||
|
||||
#endif /* __FS_H__ */
|
||||
@@ -1,191 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html>
|
||||
<head><title>lwIP - A Lightweight TCP/IP Stack - Documentation</title></head>
|
||||
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td>
|
||||
<center><h1>lwIP - A Lightweight TCP/IP Stack</h1></center>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
[Documentation]
|
||||
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td><center><h2>Documentation</h2></center>
|
||||
</td></tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0"><tr>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
<td bgcolor="white" width="540">
|
||||
|
||||
<ul>
|
||||
<li><a href="os.html">Using lwIP with and without an operating
|
||||
system</a>.
|
||||
<br><br>
|
||||
|
||||
<li>The lwIP source archive contains documentation on how to port lwIP
|
||||
and how to write applications using the native API. They can also be
|
||||
found here: <a href="doc/sys_arch.txt">sys_arch.txt</a>, <a
|
||||
href="doc/rawapi.txt">rawapi.txt</a>.
|
||||
<br><br>
|
||||
|
||||
<li>Selected messages from the mailinglist: <a
|
||||
href="maillist/msg00231.html">lwIP memory buffers and allocators</a>,
|
||||
<a href="maillist/msg00227.html">Threads, semaphores and raw interface
|
||||
question</a>, <a href="maillist/msg00242.html">Threads, semaphores and
|
||||
raw interface question [2]</a>. <a href="maillist/msg00460.html">Some notes on using lwIP with the development enviroment ADS
|
||||
1.1 from ARM.</a>
|
||||
<br><br>
|
||||
|
||||
<li>A report describing the design and implementation of an old
|
||||
version of lwIP. The algorithms and data structures used both in the
|
||||
protocol implementations and in the sub systems such as the memory and
|
||||
buffer management systems are described. Also included in this report
|
||||
is a reference manual for the lwIP sequential API and some code
|
||||
examples of using lwIP. <a href="doc/lwip.pdf">PDF</a>, <a
|
||||
href="doc/lwip.ps.gz">.ps.gz</a>.
|
||||
|
||||
<br><br>
|
||||
|
||||
<li>Slides from a presentation that talks a bit about lwIP: <a
|
||||
href="doc/pres.pdf">PDF</a> (86k), <a href="doc/pres.ps.gz">.ps.gz</a>
|
||||
(36k).
|
||||
</ul>
|
||||
|
||||
<p align="justify">
|
||||
For more documentation regarding lwIP and a proxy architecture to
|
||||
support TCP/IP communication for small clients, look in <a
|
||||
href="/~adam/publications.html">Adam Dunkels' masters thesis</a>.
|
||||
</p>
|
||||
|
||||
|
||||
<p align="justify">
|
||||
The <a href="mailinglist.html">lwIP mailing list</a> can be used to
|
||||
discuss lwIP.
|
||||
</p>
|
||||
|
||||
<p align="justify">
|
||||
For questions or suggestions, please contact the author at <a
|
||||
href="mailto:Adam Dunkels <adam@sics.se>">Adam Dunkels
|
||||
<adam@sics.se></a>.
|
||||
</p>
|
||||
|
||||
|
||||
<p align="right">
|
||||
<font size="-1"><i>
|
||||
$Date: 2002/10/19 13:00:01 $
|
||||
</i></font>
|
||||
</p>
|
||||
|
||||
|
||||
</td>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
[Documentation]
|
||||
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</td></tr><tr>
|
||||
<td>
|
||||
<div align="right">
|
||||
<a href="http://www.sics.se/~adam/">Adam Dunkels</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,232 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html>
|
||||
<head><title>lwIP - A Lightweight TCP/IP Stack - Download</title></head>
|
||||
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td>
|
||||
<center><h1>lwIP - A Lightweight TCP/IP Stack</h1></center>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
[Download]
|
||||
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td><center><h2>Download</h2></center>
|
||||
</td></tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0"><tr>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
<td bgcolor="white" width="540">
|
||||
|
||||
|
||||
<p align="justify">
|
||||
lwIP is avaliable for download provided that you read and accept <a
|
||||
href="licence.html">this</a> BSD-style license.
|
||||
</p>
|
||||
|
||||
<h3>Release versions</h3>
|
||||
<p align="justify">
|
||||
The latest version is 0.5.3. (Older versions are also provided for an
|
||||
unknown reason.)
|
||||
</p>
|
||||
<ul>
|
||||
<li>Version 0.5.3 (latest): <a
|
||||
href="download/?f=lwip-0.5.3.tar.gz">lwip-0.5.3.tar.gz</a>
|
||||
<br><br>
|
||||
|
||||
<li>
|
||||
<font size="-2">
|
||||
Obsolete versions: <a
|
||||
href="download/?f=lwip-0.5.2.tar.gz">lwip-0.5.2.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.5.1.tar.gz">lwip-0.5.1.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.5.0.tar.gz">lwip-0.5.0.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.4.2.tar.gz">lwip-0.4.2.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.4.1.tar.gz">lwip-0.4.1.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.4.tar.gz">lwip-0.4.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.3.1.tar.gz">lwip-0.3.1.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.3.tar.gz">lwip-0.3.tar.gz</a>
|
||||
<a
|
||||
href="download/?f=lwip-0.2.tar.gz">lwip-0.2.tar.gz</a>
|
||||
</font>
|
||||
<br>
|
||||
</ul>
|
||||
|
||||
<h3>Development version</h3>
|
||||
<p align="justify">
|
||||
The latest development code from the CVS is also avaliable <a
|
||||
href="download/?f=lwip-cvs.tar.gz">here</a>. Note that this code may
|
||||
very well be unstable and might not even compile.
|
||||
</p>
|
||||
|
||||
<h3>Source code online</h3>
|
||||
<p align="justify">
|
||||
Joe MacDonald has put an HTML version of the latest lwIP source code
|
||||
online at <a
|
||||
href="http://www.deserted.net/lwIP/">http://www.deserted.net/lwIP/</a>.
|
||||
</p>
|
||||
|
||||
<h3>Ports</h3>
|
||||
<p align="justify">
|
||||
Florian Shulze has ported lwIP to DJGPP/MS-DOS and to Visual C++
|
||||
6.0/Win32. They can be downloaded <a
|
||||
href="http://homepages.fh-giessen.de/~hg10836/dev/djgpp/lwipdjgpptest-0.1.zip">here</a>
|
||||
(DJGPP/MS-DOS) and <a
|
||||
href="http://homepages.fh-giessen.de/~hg10836/crowproductions/dev/lwip-win32-msvc-0.1.zip">here</a>
|
||||
(Visual C++ 6.0/Win32).
|
||||
</p>
|
||||
|
||||
<h3>Add-ons/drivers/applications</h3>
|
||||
|
||||
<h4>DHCP client</h4>
|
||||
<p align="justify">
|
||||
Leon Woestenberg from Axon Digital Design B.V. has written a CS8900a
|
||||
network interface driver and is currently developing a DHCP client for
|
||||
lwIP. They can both be found <a
|
||||
href="http://www.esrac.ele.tue.nl/~leon/lwip/">here</a>. The plan is
|
||||
to eventually integrate Leon's DHCP client in the main lwIP
|
||||
distribution.
|
||||
</p>
|
||||
|
||||
<h4>IGMPv2 implementation</h4>
|
||||
<p align="justify">
|
||||
Steve Reynolds of Citel Technologies Ltd. has donated his IGMPv2
|
||||
implementation for lwIP to the community. It is avaliable for download
|
||||
<a href="download/igmpfiles.zip">here</a> (note that the copyright and
|
||||
license differs slightly from lwIP - read the license in the igmp.c
|
||||
file). The plan is to integrate his code into the main lwIP
|
||||
distribution.
|
||||
</p>
|
||||
|
||||
<h4>Alternative BSD socket layer</h4>
|
||||
<p align="justify">
|
||||
Paul Sheer has incorporated lwIP into his PaulOS system and has
|
||||
written an alternative BSD socket layer. It is avaliable for download
|
||||
<a href="download/bsdsocket.c">here</a>. It is copyright Paul Sheer
|
||||
and licensed under the <a
|
||||
href="http://www.gnu.org/licenses/gpl.html">GNU GPL</a>.
|
||||
</p>
|
||||
|
||||
<p align="right">
|
||||
<font size="-1"><i>
|
||||
$Date: 2002/10/19 13:00:06 $
|
||||
</i></font>
|
||||
</p>
|
||||
|
||||
</td>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
[Download]
|
||||
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</td></tr><tr>
|
||||
<td>
|
||||
<div align="right">
|
||||
<a href="http://www.sics.se/~adam/">Adam Dunkels</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 724 B |
@@ -1,169 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html>
|
||||
<head><title>lwIP - A Lightweight TCP/IP Stack - lwIP source code licence</title></head>
|
||||
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td>
|
||||
<center><h1>lwIP - A Lightweight TCP/IP Stack</h1></center>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td><center><h2>lwIP source code licence</h2></center>
|
||||
</td></tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0"><tr>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
<td bgcolor="white" width="540">
|
||||
|
||||
Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
All rights reserved.<br>
|
||||
<br>
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:<br>
|
||||
<ol>
|
||||
<li> Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.<br>
|
||||
<br>
|
||||
<li> Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the
|
||||
distribution.<br>
|
||||
<br>
|
||||
<li> Neither the name of the Institute nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission. <br>
|
||||
</ol>
|
||||
<br>
|
||||
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS `AS IS' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE. <br>
|
||||
|
||||
|
||||
|
||||
<p align="right">
|
||||
<font size="-1"><i>
|
||||
$Date: 2002/10/19 13:00:01 $
|
||||
</i></font>
|
||||
</p>
|
||||
|
||||
</td>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</td></tr><tr>
|
||||
<td>
|
||||
<div align="right">
|
||||
<a href="http://www.sics.se/~adam/">Adam Dunkels</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,266 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html>
|
||||
<head><title>lwIP - A Lightweight TCP/IP Stack - Links</title></head>
|
||||
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td>
|
||||
<center><h1>lwIP - A Lightweight TCP/IP Stack</h1></center>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
[Links]
|
||||
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td><center><h2>Links</h2></center>
|
||||
</td></tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0"><tr>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
<td bgcolor="white" width="540">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
lwIP pages:
|
||||
<ul>
|
||||
<li><a href="http://www.esrac.ele.tue.nl/~leon/lwip/">Leon Woestenberg's lwIP page</a>
|
||||
</ul>
|
||||
|
||||
Companies using lwIP in their products:
|
||||
<ul>
|
||||
<li>UK based <a href="http://www.tangentdevices.co.uk/">Tangent Devices Ltd</a> are incorporating lwIP in their film
|
||||
and video post-production equipment.
|
||||
<li><a href="http://www.axon.tv">Axon Digital Design BV</a> in The
|
||||
Netherlands is merging lwIP with their current IP stack for use in the
|
||||
Synapse modular broadcasting system.
|
||||
</ul>
|
||||
|
||||
Projects using lwIP:
|
||||
<ul>
|
||||
<li><a href="http://www.cdt.luth.se/projects/arena/">The ARENA Project</a> - Hockey players equipped with pulse and breathing sensors running lwIP.<br>
|
||||
<li><a href="http://bart.sm.luth.se/eis2001/">The Embedded Internet Systems 2001 Student Project</a> - Flow meter and belt tension sensors
|
||||
running lwIP.<br>
|
||||
<li><a href="http://dcdev.allusion.net/">KOS</a> - The KOS operating system for
|
||||
Sega Dreamcast uses lwIP.<br>
|
||||
</ul>
|
||||
|
||||
Other small TCP/IP implementations:
|
||||
<ul>
|
||||
<li><a href="http://dunkels.com/adam/uip/">uIP</a> - A very small TCP/IP
|
||||
implementation, suitable for systems with hundreds of bytes free RAM
|
||||
and a few kilobytes of free code space.<br>
|
||||
<li><a href="http://ucip.sourceforge.net/">uC/IP</a> - uC/IP is a BSD-based
|
||||
TCP/IP protocol stack for microcontrollers.<br>
|
||||
<li><a href="http://liquorice.sourceforge.net">Liquorice</a> - Liquorice
|
||||
includes a TCP/IP stack.<br>
|
||||
<li><a href="http://www.nenie.org/cpcip/">CPC/IP</a> - A TCP/IP stack for
|
||||
Amstrad CPCs.<br>
|
||||
<li><a href="http://lng.sourceforge.net/">LUnix</a> - LUnix contains a small
|
||||
TCP/IP stack.<br>
|
||||
<li><a href="http://www.sweetcherrie.com/jolz64/jos/">JOS</a> - JOS includes a
|
||||
TCP/IP implementation.<br>
|
||||
<li><a href="http://www.csonline.net/bpaddock/tinytcp/default.htm">TinyTCP</a> - A very slim
|
||||
TCP, IP, and FTP implementation.<br>
|
||||
<li><a href="http://kyllikki.fluff.org/hardware/wwwpic2/">WWWpic2</a> - Small
|
||||
HTTP/TCP/IP implementation for a PIC.<br>
|
||||
<li><a href="http://www.rmbeales.fsnet.co.uk/files/html/picserver/picservd.htm">PIC Web Server</a> - Small HTTP/TCP/IP/SLIP PIC implementation.<br>
|
||||
</ul>
|
||||
|
||||
Very small web servers:
|
||||
<ul>
|
||||
<li><a href="http://world.std.com/~fwhite/ace/">webACE</a> - World's Smallest
|
||||
Web Server.<br>
|
||||
<li><a href="http://www-ccs.cs.umass.edu/~shri/iPic.html">iPIC</a> - A Match
|
||||
Head Sized Web Server.<br>
|
||||
</ul>
|
||||
|
||||
Related RFCs:
|
||||
<ul>
|
||||
<li>J. Postel, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc791.txt">Internet Protocol</a>, RFC791, September 1981.
|
||||
<li>J. Postel, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc792.txt">Internet Control Message Protocol</a>, RFC792, September 1981.
|
||||
<li>J. Postel, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc768.txt">User Datagram Protocol</a>, RFC768, August 1980.
|
||||
<li>J. Postel, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc793.txt">Transmission Control Protocol</a>, RFC793, September 1981.
|
||||
<li>D. D. Clark, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc813.txt">Window and Acknowledgement Strategy in TCP</a>, RFC813, July 1982.
|
||||
<li>D. D. Clark, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc817.txt">Modularity and Efficiency in Protocol Implementation</a>, RFC817, July 1982.
|
||||
<li>R. Braden, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc1122.txt">Requirements for Internet Hosts -- Communication Layers</a>, RFC1122, October 1989.
|
||||
<li>T. Mallory and A. Kullberg, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc1141.txt">Incremental Updating of the Internet Checksum</a>, RFC1141, January 1990.
|
||||
<li>A. Rijsinghani, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc1624.txt">Computation of the Internet Checksum via Incremental Update</a>, RFC1624, May 1994.
|
||||
<li>R. Braden, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc1337.txt">TIME-WAIT Assasination Hazards in TCP</a>, RFC1337, May 1992.
|
||||
<li>B. Carpenter, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc1958.txt">Architectural Principles of the Internet</a>, RFC1958, June 1996.
|
||||
<li>M. Allman, V. Paxson and W. Stevens, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc2581.txt">TCP Congestion Control</a>, RFC2581, April 1999.
|
||||
<li>S. Parker and C. Schmechel, <a
|
||||
href="ftp://ftp.ietf.org/rfc/rfc2398.txt">Some Testing Tools for TCP Implementors</a>, RFC2398, August 1998.
|
||||
</ul>
|
||||
|
||||
Related publications:
|
||||
<ul>
|
||||
<li>V. Jacobson. Congestion avoidance and control. In <i>Proceedings of
|
||||
the SIGCOMM '88 Conference</i>, Stanford, California, August 1988.
|
||||
<li>V. Jacobson. 4.3BSD TCP header prediction. <i>ACM Computer
|
||||
Communications Review</i>, 20(2), April 1990.
|
||||
<li>P. Karn and C. Partridge. Improving round-trip time estimates
|
||||
in reliablie transport protocols. In <i>Proceedings of the SIGCOMM '87
|
||||
Conference</i>, Stowe, Vermont, August 1987.
|
||||
<li>J. Kay and J. Pasquale. Profiling and Reducing Processing
|
||||
Overheads in TCP/IP. <i>IEEE/ACM Transactions of Networking</i>, 4(6), December 1996.
|
||||
<li>L. Larzon, M. Degermark, and S. Pink. UDP Lite for
|
||||
real-time multimedia applications. In <i>Proceedings of the IEEE
|
||||
International Conference of Communications</i>, Vancouver, British
|
||||
Columbia, Canada, June 1999.
|
||||
<li>P. E. McKenney and K. F. Dove. Efcient demultiplexing of
|
||||
incoming TCP packets. In <i>Proceedings of the SIGCOMM '92 Conference</i>, Baltimore, Maryland, August 1992.
|
||||
<li>C. Partridge and S. Pink. A faster UDP. <i>IEEE/ACM Transactions
|
||||
in Networking</i>, 1(4), August 1993.
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<p align="right">
|
||||
<font size="-1"><i>
|
||||
$Date: 2002/10/19 13:00:02 $
|
||||
</i></font>
|
||||
</p>
|
||||
|
||||
|
||||
</td>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
[Links]
|
||||
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</td></tr><tr>
|
||||
<td>
|
||||
<div align="right">
|
||||
<a href="http://www.sics.se/~adam/">Adam Dunkels</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,187 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html>
|
||||
<head><title>lwIP - A Lightweight TCP/IP Stack - Mailing list</title></head>
|
||||
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td>
|
||||
<center><h1>lwIP - A Lightweight TCP/IP Stack</h1></center>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
[Mailing list]
|
||||
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td><center><h2>Mailing list</h2></center>
|
||||
</td></tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0"><tr>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
<td bgcolor="white" width="540">
|
||||
|
||||
|
||||
<p align="justify">
|
||||
The lwIP mailing list is the place to discuss lwIP. All topics related
|
||||
to lwIP, such as porting or using lwIP, writing device drivers or
|
||||
application programs for lwIP can be discussed here.
|
||||
</p>
|
||||
|
||||
<h3>Archives</h3>
|
||||
<p align="justify">
|
||||
Archives can be found <a href="maillist/">here</a>.
|
||||
</p>
|
||||
|
||||
<h3>Subscribe</h3>
|
||||
<p align="justify">
|
||||
To subscribe, send a mail to <a
|
||||
href="mailto:majordomo@sics.se">majordomo@sics.se</a> with the message
|
||||
<pre>
|
||||
subscribe lwip
|
||||
|
||||
</pre>
|
||||
in the message body. The subject should be kept blank.
|
||||
</p>
|
||||
<p align="justify">
|
||||
In a few minutes, you should receive a welcome message and some
|
||||
information regarding the subscription, including instructions for
|
||||
unsubscribing. Save those messages for future reference.
|
||||
</p>
|
||||
|
||||
<p align="justify">
|
||||
You are now an lwIP mailing list subscriber!
|
||||
</p>
|
||||
|
||||
<h3>Post</h3>
|
||||
<p align="justify">
|
||||
Posting to the lwIP mailing list is a simple as sending a mail to the
|
||||
address <a href="mailto:lwip@sics.se">lwip@sics.se</a>.
|
||||
</p>
|
||||
|
||||
<h3>Unsubscribe</h3>
|
||||
<p align="justify">
|
||||
To subscribe, send a mail to <a
|
||||
href="mailto:majordomo@sics.se">majordomo@sics.se</a> with the message
|
||||
<pre>
|
||||
unsubscribe lwip
|
||||
|
||||
</pre>
|
||||
in the message body. The subject should be kept blank.
|
||||
</p>
|
||||
|
||||
<p align="right">
|
||||
<font size="-1"><i>
|
||||
$Date: 2002/10/19 13:00:02 $
|
||||
</i></font>
|
||||
</p>
|
||||
|
||||
|
||||
</td>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
[Mailing list]
|
||||
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</td></tr><tr>
|
||||
<td>
|
||||
<div align="right">
|
||||
<a href="http://www.sics.se/~adam/">Adam Dunkels</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,225 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<html>
|
||||
<head><title>lwIP - A Lightweight TCP/IP Stack - OS vs non-OS</title></head>
|
||||
|
||||
|
||||
<body bgcolor="white">
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td>
|
||||
<center><h1>lwIP - A Lightweight TCP/IP Stack</h1></center>
|
||||
</td></tr></table>
|
||||
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td><center><h2>OS vs non-OS</h2></center>
|
||||
</td></tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0"><tr>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
<td bgcolor="white" width="540">
|
||||
|
||||
<h2>Using lwIP with or without an operating system</h2>
|
||||
|
||||
<p align="justify">
|
||||
There has been a few questions about how lwIP can be used in a
|
||||
standalone environment (i.e., an environment without a multi-threaded
|
||||
operating system) lately. The purpose of this document is to describe
|
||||
how lwIP is designed to be used with and without a multi-threaded
|
||||
operating system.
|
||||
</p>
|
||||
|
||||
<center><img src="os.png"></center>
|
||||
|
||||
<h3>The lwIP single-threaded core</h3>
|
||||
<p align="justify">
|
||||
The core of lwIP consists of the actual implementations of the IP,
|
||||
ICMP, UDP, and TCP protocols, as well as the support functions such as
|
||||
buffer and memory management. The core components are the only ones
|
||||
that are needed when lwIP is to be run in a single-threaded (non-OS)
|
||||
environment.
|
||||
</p>
|
||||
<p align="justify">
|
||||
The core components can be viewed as a software library which has the
|
||||
following interface:
|
||||
</p>
|
||||
<ul>
|
||||
<li><tt>ip_input(pbuf, netif)</tt>: Takes an IP packet and the incoming network
|
||||
interface as arguments and does the TCP/IP processing for the packet.
|
||||
<li><tt>tcp_tmr()</tt>: Should be called every 100 ms. Does all TCP
|
||||
timer processing such as doing retransmissions.
|
||||
</ul>
|
||||
<p align="justify">
|
||||
Because none of the core functions ever needs to block when run in a
|
||||
single-threaded environment, the <tt>sys_arch</tt> (the operating
|
||||
system abstraction layer) does not need to implement locking
|
||||
semaphores or mailboxes. In future versions of lwIP, the dependancy of
|
||||
the <tt>sys_arch</tt> will be removed in the single-threaded case.
|
||||
</p>
|
||||
<p align="justify">
|
||||
A simple main loop for a single-threaded system might look
|
||||
like this:
|
||||
</p>
|
||||
<pre>
|
||||
while(1) {
|
||||
if(poll_driver(netif) == PACKET_READY) {
|
||||
pbuf = get_packet(netif);
|
||||
ip_input(pbuf, netif);
|
||||
}
|
||||
|
||||
if(clock() - last_time == 100 * CLOCK_MS) {
|
||||
tcp_tmr();
|
||||
last_time = clock();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3>lwIP in a multi-threaded system</h3>
|
||||
<p align="justify">
|
||||
lwIP is designed to be able to be run in a multi-threaded system with
|
||||
applications running in concurrent threads. The model used in this
|
||||
case is that all TCP/IP processing is done in a single thread. The
|
||||
application thread communicate with the TCP/IP thread using the
|
||||
sequential API.
|
||||
</p>
|
||||
|
||||
<center><img src="threads.png"></center>
|
||||
|
||||
<p align="justify">
|
||||
The inter-thread communication is implemented in the two files
|
||||
<tt>api_lib.c</tt> and <tt>api_msg.c</tt>. The former contains the
|
||||
functions used by the application programs and the latter implements
|
||||
the TCP/IP stack interface. A third file, <tt>tcpip.c</tt>, handles
|
||||
incoming packets and timer events as described in the previous
|
||||
section.
|
||||
</p>
|
||||
|
||||
<p align="justify">
|
||||
When run in a multi-threaded environment, incoming packets are handled
|
||||
by the function <tt>tcpip_input()</tt>, which takes the same arguments
|
||||
as the <tt>ip_input()</tt> function. The difference between the two
|
||||
functions is that the <tt>tcpip_input()</tt> function does not process
|
||||
the incoming packet immediately. It merely puts the packet on a queue
|
||||
which later is drained by the TCP/IP thread.
|
||||
</p>
|
||||
|
||||
<p align="justify">
|
||||
When being run in a multi-threaded system, timer events are taken care
|
||||
of internally in <tt>tcpip.c</tt>.
|
||||
</p>
|
||||
|
||||
<p align="right">
|
||||
<font size="-1"><i>
|
||||
$Date: 2002/10/19 13:00:03 $
|
||||
</i></font>
|
||||
</p>
|
||||
|
||||
|
||||
</td>
|
||||
<td width="50">
|
||||
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
<table width="640" border="0" cellpadding="0"
|
||||
cellspacing="0">
|
||||
<tr><td align="center">
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="index.html">Introduction</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="news.html">News</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="documentation.html">Documentation</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="mailinglist.html">Mailing list</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="changelog.html">Changelog</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="download.html">Download</a>
|
||||
|
||||
|
|
||||
|
||||
<a href="links.html">Links</a>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</td></tr><tr>
|
||||
<td>
|
||||
<div align="right">
|
||||
<a href="http://www.sics.se/~adam/">Adam Dunkels</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB |
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __FSDATA_H__
|
||||
#define __FSDATA_H__
|
||||
|
||||
struct fsdata_file {
|
||||
const struct fsdata_file *next;
|
||||
const char *name;
|
||||
const char *data;
|
||||
const int len;
|
||||
};
|
||||
|
||||
struct fsdata_file_noconst {
|
||||
struct fsdata_file *next;
|
||||
char *name;
|
||||
char *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
#endif /* __FSDATA_H__ */
|
||||
@@ -1,244 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#include "httpd.h"
|
||||
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "fs.h"
|
||||
|
||||
struct http_state {
|
||||
char *file;
|
||||
u32_t left;
|
||||
u8_t retries;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
conn_err(void *arg, err_t err)
|
||||
{
|
||||
struct http_state *hs;
|
||||
|
||||
hs = arg;
|
||||
mem_free(hs);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
close_conn(struct tcp_pcb *pcb, struct http_state *hs)
|
||||
{
|
||||
tcp_arg(pcb, NULL);
|
||||
tcp_sent(pcb, NULL);
|
||||
tcp_recv(pcb, NULL);
|
||||
mem_free(hs);
|
||||
tcp_close(pcb);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
send_data(struct tcp_pcb *pcb, struct http_state *hs)
|
||||
{
|
||||
err_t err;
|
||||
u16_t len;
|
||||
|
||||
/* We cannot send more data than space avaliable in the send
|
||||
buffer. */
|
||||
if(tcp_sndbuf(pcb) < hs->left) {
|
||||
len = tcp_sndbuf(pcb);
|
||||
} else {
|
||||
len = hs->left;
|
||||
}
|
||||
|
||||
do {
|
||||
err = tcp_write(pcb, hs->file, len, 0);
|
||||
if(err == ERR_MEM) {
|
||||
len /= 2;
|
||||
}
|
||||
} while(err == ERR_MEM && len > 1);
|
||||
|
||||
if(err == ERR_OK) {
|
||||
hs->file += len;
|
||||
hs->left -= len;
|
||||
/* } else {
|
||||
printf("send_data: error %s len %d %d\n", lwip_strerr(err), len, tcp_sndbuf(pcb));*/
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
http_poll(void *arg, struct tcp_pcb *pcb)
|
||||
{
|
||||
struct http_state *hs;
|
||||
|
||||
hs = arg;
|
||||
|
||||
/* printf("Polll\n");*/
|
||||
if(hs == NULL) {
|
||||
/* printf("Null, close\n");*/
|
||||
tcp_abort(pcb);
|
||||
return ERR_ABRT;
|
||||
} else {
|
||||
++hs->retries;
|
||||
if(hs->retries == 4) {
|
||||
tcp_abort(pcb);
|
||||
return ERR_ABRT;
|
||||
}
|
||||
send_data(pcb, hs);
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||
{
|
||||
struct http_state *hs;
|
||||
|
||||
hs = arg;
|
||||
|
||||
hs->retries = 0;
|
||||
|
||||
if(hs->left > 0) {
|
||||
send_data(pcb, hs);
|
||||
} else {
|
||||
close_conn(pcb, hs);
|
||||
}
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
{
|
||||
int i;
|
||||
char *data;
|
||||
struct fs_file file;
|
||||
struct http_state *hs;
|
||||
|
||||
hs = arg;
|
||||
|
||||
if(err == ERR_OK && p != NULL) {
|
||||
|
||||
/* Inform TCP that we have taken the data. */
|
||||
tcp_recved(pcb, p->tot_len);
|
||||
|
||||
if(hs->file == NULL) {
|
||||
data = p->payload;
|
||||
|
||||
if(strncmp(data, "GET ", 4) == 0) {
|
||||
for(i = 0; i < 40; i++) {
|
||||
if(((char *)data + 4)[i] == ' ' ||
|
||||
((char *)data + 4)[i] == '\r' ||
|
||||
((char *)data + 4)[i] == '\n') {
|
||||
((char *)data + 4)[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(*(char *)(data + 4) == '/' &&
|
||||
*(char *)(data + 5) == 0) {
|
||||
fs_open("/index.html", &file);
|
||||
} else if(!fs_open((char *)data + 4, &file)) {
|
||||
fs_open("/404.html", &file);
|
||||
}
|
||||
hs->file = file.data;
|
||||
hs->left = file.len;
|
||||
/* printf("data %p len %ld\n", hs->file, hs->left);*/
|
||||
|
||||
pbuf_free(p);
|
||||
send_data(pcb, hs);
|
||||
|
||||
/* Tell TCP that we wish be to informed of data that has been
|
||||
successfully sent by a call to the http_sent() function. */
|
||||
tcp_sent(pcb, http_sent);
|
||||
} else {
|
||||
pbuf_free(p);
|
||||
close_conn(pcb, hs);
|
||||
}
|
||||
} else {
|
||||
pbuf_free(p);
|
||||
}
|
||||
}
|
||||
|
||||
if(err == ERR_OK && p == NULL) {
|
||||
close_conn(pcb, hs);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
{
|
||||
struct http_state *hs;
|
||||
|
||||
tcp_setprio(pcb, TCP_PRIO_MIN);
|
||||
|
||||
/* Allocate memory for the structure that holds the state of the
|
||||
connection. */
|
||||
hs = mem_malloc(sizeof(struct http_state));
|
||||
|
||||
if(hs == NULL) {
|
||||
printf("http_accept: Out of memory\n");
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
/* Initialize the structure. */
|
||||
hs->file = NULL;
|
||||
hs->left = 0;
|
||||
hs->retries = 0;
|
||||
|
||||
/* Tell TCP that this is the structure we wish to be passed for our
|
||||
callbacks. */
|
||||
tcp_arg(pcb, hs);
|
||||
|
||||
/* Tell TCP that we wish to be informed of incoming data by a call
|
||||
to the http_recv() function. */
|
||||
tcp_recv(pcb, http_recv);
|
||||
|
||||
tcp_err(pcb, conn_err);
|
||||
|
||||
tcp_poll(pcb, http_poll, 4);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_init(void)
|
||||
{
|
||||
struct tcp_pcb *pcb;
|
||||
|
||||
pcb = tcp_new();
|
||||
tcp_bind(pcb, IP_ADDR_ANY, 80);
|
||||
pcb = tcp_listen(pcb);
|
||||
tcp_accept(pcb, http_accept);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __HTTPD_H__
|
||||
#define __HTTPD_H__
|
||||
|
||||
void httpd_init(void);
|
||||
|
||||
#endif /* __HTTPD_H__ */
|
||||
@@ -1,97 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
open(OUTPUT, "> fsdata.c");
|
||||
|
||||
chdir("fs");
|
||||
open(FILES, "find . -type f |");
|
||||
|
||||
while($file = <FILES>) {
|
||||
|
||||
# Do not include files in CVS directories nor backup files.
|
||||
if($file =~ /(CVS|~)/) {
|
||||
next;
|
||||
}
|
||||
|
||||
chop($file);
|
||||
|
||||
open(HEADER, "> /tmp/header") || die $!;
|
||||
if($file =~ /404/) {
|
||||
print(HEADER "HTTP/1.0 404 File not found\r\n");
|
||||
} else {
|
||||
print(HEADER "HTTP/1.0 200 OK\r\n");
|
||||
}
|
||||
print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n");
|
||||
if($file =~ /\.html$/) {
|
||||
print(HEADER "Content-type: text/html\r\n");
|
||||
} elsif($file =~ /\.gif$/) {
|
||||
print(HEADER "Content-type: image/gif\r\n");
|
||||
} elsif($file =~ /\.png$/) {
|
||||
print(HEADER "Content-type: image/png\r\n");
|
||||
} elsif($file =~ /\.jpg$/) {
|
||||
print(HEADER "Content-type: image/jpeg\r\n");
|
||||
} elsif($file =~ /\.class$/) {
|
||||
print(HEADER "Content-type: application/octet-stream\r\n");
|
||||
} elsif($file =~ /\.ram$/) {
|
||||
print(HEADER "Content-type: audio/x-pn-realaudio\r\n");
|
||||
} else {
|
||||
print(HEADER "Content-type: text/plain\r\n");
|
||||
}
|
||||
print(HEADER "\r\n");
|
||||
close(HEADER);
|
||||
|
||||
unless($file =~ /\.plain$/ || $file =~ /cgi/) {
|
||||
system("cat /tmp/header $file > /tmp/file");
|
||||
} else {
|
||||
system("cp $file /tmp/file");
|
||||
}
|
||||
|
||||
open(FILE, "/tmp/file");
|
||||
unlink("/tmp/file");
|
||||
unlink("/tmp/header");
|
||||
|
||||
$file =~ s/\.//;
|
||||
$fvar = $file;
|
||||
$fvar =~ s-/-_-g;
|
||||
$fvar =~ s-\.-_-g;
|
||||
print(OUTPUT "static const char data".$fvar."[] = {\n");
|
||||
print(OUTPUT "\t/* $file */\n\t");
|
||||
for($j = 0; $j < length($file); $j++) {
|
||||
printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
|
||||
}
|
||||
printf(OUTPUT "0,\n");
|
||||
|
||||
|
||||
$i = 0;
|
||||
while(read(FILE, $data, 1)) {
|
||||
if($i == 0) {
|
||||
print(OUTPUT "\t");
|
||||
}
|
||||
printf(OUTPUT "%#02x, ", unpack("C", $data));
|
||||
$i++;
|
||||
if($i == 10) {
|
||||
print(OUTPUT "\n");
|
||||
$i = 0;
|
||||
}
|
||||
}
|
||||
print(OUTPUT "};\n\n");
|
||||
close(FILE);
|
||||
push(@fvars, $fvar);
|
||||
push(@files, $file);
|
||||
}
|
||||
|
||||
for($i = 0; $i < @fvars; $i++) {
|
||||
$file = $files[$i];
|
||||
$fvar = $fvars[$i];
|
||||
|
||||
if($i == 0) {
|
||||
$prevfile = "NULL";
|
||||
} else {
|
||||
$prevfile = "file" . $fvars[$i - 1];
|
||||
}
|
||||
print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
|
||||
print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
|
||||
print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
|
||||
}
|
||||
|
||||
print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n");
|
||||
print(OUTPUT "#define FS_NUMFILES $i");
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __SHELL_H__
|
||||
#define __SHELL_H__
|
||||
|
||||
void shell_init(void);
|
||||
|
||||
#endif /* __SHELL_H__ */
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/api.h"
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcpecho_thread(void *arg)
|
||||
{
|
||||
struct netconn *conn, *newconn;
|
||||
err_t err;
|
||||
|
||||
/* Create a new connection identifier. */
|
||||
conn = netconn_new(NETCONN_TCP);
|
||||
|
||||
/* Bind connection to well known port number 7. */
|
||||
netconn_bind(conn, NULL, 7);
|
||||
|
||||
/* Tell connection to go into listening mode. */
|
||||
netconn_listen(conn);
|
||||
|
||||
while(1) {
|
||||
|
||||
/* Grab new connection. */
|
||||
newconn = netconn_accept(conn);
|
||||
/*printf("accepted new connection %p\n", newconn);*/
|
||||
/* Process the new connection. */
|
||||
if(newconn != NULL) {
|
||||
struct netbuf *buf;
|
||||
void *data;
|
||||
u16_t len;
|
||||
|
||||
while((buf = netconn_recv(newconn)) != NULL) {
|
||||
/*printf("Recved\n");*/
|
||||
do {
|
||||
netbuf_data(buf, &data, &len);
|
||||
err = netconn_write(newconn, data, len, NETCONN_COPY);
|
||||
if(err != ERR_OK) {
|
||||
/* printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));*/
|
||||
}
|
||||
} while(netbuf_next(buf) >= 0);
|
||||
netbuf_delete(buf);
|
||||
}
|
||||
/*printf("Got EOF, looping\n");*/
|
||||
/* Close connection and discard connection identifier. */
|
||||
netconn_delete(newconn);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
tcpecho_init(void)
|
||||
{
|
||||
sys_thread_new(tcpecho_thread, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __TCPECHO_H__
|
||||
#define __TCPECHO_H__
|
||||
|
||||
void tcpecho_init(void);
|
||||
|
||||
#endif /* __TCPECHO_H__ */
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/api.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
udpecho_thread(void *arg)
|
||||
{
|
||||
static struct netconn *conn;
|
||||
static struct netbuf *buf;
|
||||
static struct ip_addr *addr;
|
||||
static unsigned short port;
|
||||
char buffer[4096];
|
||||
|
||||
conn = netconn_new(NETCONN_UDP);
|
||||
netconn_bind(conn, NULL, 7);
|
||||
|
||||
while(1) {
|
||||
buf = netconn_recv(conn);
|
||||
addr = netbuf_fromaddr(buf);
|
||||
port = netbuf_fromport(buf);
|
||||
netconn_connect(conn, addr, port);
|
||||
netconn_send(conn, buf);
|
||||
netbuf_copy(buf, buffer, sizeof(buffer));
|
||||
printf("got %s\n", buffer);
|
||||
netbuf_delete(buf);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
udpecho_init(void)
|
||||
{
|
||||
sys_thread_new(udpecho_thread, NULL);
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __UDPECHO_H__
|
||||
#define __UDPECHO_H__
|
||||
|
||||
void udpecho_init(void);
|
||||
|
||||
#endif /* __UDPECHO_H__ */
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
/* ---------- Memory options ---------- */
|
||||
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
|
||||
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
|
||||
byte alignment -> define MEM_ALIGNMENT to 2. */
|
||||
#define MEM_ALIGNMENT 1
|
||||
|
||||
/* MEM_SIZE: the size of the heap memory. If the application will send
|
||||
a lot of data that needs to be copied, this should be set high. */
|
||||
#define MEM_SIZE 1600
|
||||
|
||||
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
|
||||
sends a lot of data out of ROM (or other static memory), this
|
||||
should be set high. */
|
||||
#define MEMP_NUM_PBUF 16
|
||||
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
|
||||
per active UDP "connection". */
|
||||
#define MEMP_NUM_UDP_PCB 4
|
||||
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB 5
|
||||
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
|
||||
connections. */
|
||||
#define MEMP_NUM_TCP_PCB_LISTEN 8
|
||||
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
|
||||
segments. */
|
||||
#define MEMP_NUM_TCP_SEG 16
|
||||
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
|
||||
timeouts. */
|
||||
#define MEMP_NUM_SYS_TIMEOUT 3
|
||||
|
||||
|
||||
/* The following four are used only with the sequential API and can be
|
||||
set to 0 if the application only will use the raw API. */
|
||||
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
|
||||
#define MEMP_NUM_NETBUF 2
|
||||
/* MEMP_NUM_NETCONN: the number of struct netconns. */
|
||||
#define MEMP_NUM_NETCONN 4
|
||||
/* MEMP_NUM_APIMSG: the number of struct api_msg, used for
|
||||
communication between the TCP/IP stack and the sequential
|
||||
programs. */
|
||||
#define MEMP_NUM_API_MSG 8
|
||||
/* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used
|
||||
for sequential API communication and incoming packets. Used in
|
||||
src/api/tcpip.c. */
|
||||
#define MEMP_NUM_TCPIP_MSG 8
|
||||
|
||||
/* These two control is reclaimer functions should be compiled
|
||||
in. Should always be turned on (1). */
|
||||
#define MEM_RECLAIM 1
|
||||
#define MEMP_RECLAIM 1
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#define PBUF_POOL_SIZE 6
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
#define PBUF_POOL_BUFSIZE 128
|
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. */
|
||||
#define PBUF_LINK_HLEN 16
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
order. Define to 0 if your device is low on memory. */
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
|
||||
/* TCP Maximum segment size. */
|
||||
#define TCP_MSS 128
|
||||
|
||||
/* TCP sender buffer space (bytes). */
|
||||
#define TCP_SND_BUF 256
|
||||
|
||||
/* TCP sender buffer space (pbufs). This must be at least = 2 *
|
||||
TCP_SND_BUF/TCP_MSS for things to work. */
|
||||
#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS
|
||||
|
||||
/* TCP receive window. */
|
||||
#define TCP_WND 1024
|
||||
|
||||
/* Maximum number of retransmissions of data segments. */
|
||||
#define TCP_MAXRTX 12
|
||||
|
||||
/* Maximum number of retransmissions of SYN segments. */
|
||||
#define TCP_SYNMAXRTX 4
|
||||
|
||||
/* ---------- ARP options ---------- */
|
||||
#define ARP_TABLE_SIZE 10
|
||||
|
||||
/* ---------- IP options ---------- */
|
||||
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
|
||||
IP packets across network interfaces. If you are going to run lwIP
|
||||
on a device with only one network interface, define this to 0. */
|
||||
#define IP_FORWARD 1
|
||||
|
||||
/* If defined to 1, IP options are allowed (but not parsed). If
|
||||
defined to 0, all packets with IP options are dropped. */
|
||||
#define IP_OPTIONS 1
|
||||
|
||||
/* ---------- ICMP options ---------- */
|
||||
#define ICMP_TTL 255
|
||||
|
||||
|
||||
/* ---------- DHCP options ---------- */
|
||||
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
|
||||
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
|
||||
turning this on does currently not work. */
|
||||
#define LWIP_DHCP 0
|
||||
|
||||
/* 1 if you want to do an ARP check on the offered address
|
||||
(recommended). */
|
||||
#define DHCP_DOES_ARP_CHECK 1
|
||||
|
||||
/* ---------- UDP options ---------- */
|
||||
#define LWIP_UDP 1
|
||||
#define UDP_TTL 255
|
||||
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define STATS
|
||||
|
||||
#ifdef STATS
|
||||
#define LINK_STATS
|
||||
#define IP_STATS
|
||||
#define ICMP_STATS
|
||||
#define UDP_STATS
|
||||
#define TCP_STATS
|
||||
#define MEM_STATS
|
||||
#define MEMP_STATS
|
||||
#define PBUF_STATS
|
||||
#define SYS_STATS
|
||||
#endif /* STATS */
|
||||
|
||||
#endif /* __LWIPOPTS_H__ */
|
||||
@@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
|
||||
#include "netif/tapif.h"
|
||||
#include "netif/tunif.h"
|
||||
|
||||
#include "netif/unixif.h"
|
||||
#include "netif/dropif.h"
|
||||
#include "netif/pcapif.h"
|
||||
#include "netif/loopif.h"
|
||||
|
||||
#include "netif/tcpdump.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "arch/perf.h"
|
||||
|
||||
#include "httpd.h"
|
||||
#include "udpecho.h"
|
||||
#include "tcpecho.h"
|
||||
#include "shell.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcp_timeout(void *data)
|
||||
{
|
||||
#if TCP_DEBUG
|
||||
tcp_debug_print_pcbs();
|
||||
#endif /* TCP_DEBUG */
|
||||
sys_timeout(5000, tcp_timeout, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcpip_init_done(void *arg)
|
||||
{
|
||||
sys_sem_t *sem;
|
||||
sem = arg;
|
||||
sys_sem_signal(*sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
main_thread(void *arg)
|
||||
{
|
||||
struct ip_addr ipaddr, netmask, gw;
|
||||
sys_sem_t sem;
|
||||
|
||||
netif_init();
|
||||
|
||||
sem = sys_sem_new(0);
|
||||
tcpip_init(tcpip_init_done, &sem);
|
||||
sys_sem_wait(sem);
|
||||
sys_sem_free(sem);
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
#if LWIP_DHCP
|
||||
{
|
||||
struct netif *netif;
|
||||
IP4_ADDR(&gw, 0,0,0,0);
|
||||
IP4_ADDR(&ipaddr, 0,0,0,0);
|
||||
IP4_ADDR(&netmask, 0,0,0,0);
|
||||
|
||||
netif = netif_add(&ipaddr, &netmask, &gw, tapif_init,
|
||||
tcpip_input);
|
||||
netif_set_default(netif);
|
||||
dhcp_init();
|
||||
dhcp_start(netif);
|
||||
}
|
||||
#else
|
||||
IP4_ADDR(&gw, 192,168,0,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,0,2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
/* netif_set_default(netif_add(&ipaddr, &netmask, &gw, tapif_init,
|
||||
tcpip_input));*/
|
||||
netif_set_default(netif_add(&ipaddr, &netmask, &gw, tapif_init,
|
||||
tcpip_input));
|
||||
#endif
|
||||
/* Only used for testing purposes: */
|
||||
/* IP4_ADDR(&gw, 193,10,66,1);
|
||||
IP4_ADDR(&ipaddr, 193,10,66,107);
|
||||
IP4_ADDR(&netmask, 255,255,252,0);
|
||||
|
||||
netif_add(&ipaddr, &netmask, &gw, pcapif_init,
|
||||
tcpip_input);*/
|
||||
|
||||
IP4_ADDR(&gw, 127,0,0,1);
|
||||
IP4_ADDR(&ipaddr, 127,0,0,1);
|
||||
IP4_ADDR(&netmask, 255,0,0,0);
|
||||
|
||||
netif_add(&ipaddr, &netmask, &gw, loopif_init,
|
||||
tcpip_input);
|
||||
|
||||
tcpecho_init();
|
||||
shell_init();
|
||||
httpd_init();
|
||||
udpecho_init();
|
||||
|
||||
printf("Applications started.\n");
|
||||
|
||||
/* sys_timeout(5000, tcp_timeout, NULL);*/
|
||||
|
||||
#ifdef MEM_PERF
|
||||
mem_perf_init("/tmp/memstats.client");
|
||||
#endif /* MEM_PERF */
|
||||
|
||||
/* Block for ever. */
|
||||
sem = sys_sem_new(0);
|
||||
sys_sem_wait(sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef PERF
|
||||
perf_init("/tmp/simhost.perf");
|
||||
#endif /* PERF */
|
||||
#ifdef STATS
|
||||
stats_init();
|
||||
#endif /* STATS */
|
||||
sys_init();
|
||||
mem_init();
|
||||
memp_init();
|
||||
pbuf_init();
|
||||
|
||||
tcpdump_init();
|
||||
|
||||
|
||||
printf("System initialized.\n");
|
||||
|
||||
sys_thread_new((void *)(main_thread), NULL);
|
||||
pause();
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
|
||||
|
||||
#include "netif/unixif.h"
|
||||
#include "netif/dropif.h"
|
||||
|
||||
#include "netif/loopif.h"
|
||||
|
||||
#include "netif/tcpdump.h"
|
||||
|
||||
#include "netif/sioslipif.h"
|
||||
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "arch/perf.h"
|
||||
|
||||
#include "httpd.h"
|
||||
#include "udpecho.h"
|
||||
#include "tcpecho.h"
|
||||
#include "shell.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcp_timeout(void *data)
|
||||
{
|
||||
#if TCP_DEBUG
|
||||
tcp_debug_print_pcbs();
|
||||
#endif /* TCP_DEBUG */
|
||||
sys_timeout(5000, tcp_timeout, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcpip_init_done(void *arg)
|
||||
{
|
||||
sys_sem_t *sem;
|
||||
sem = arg;
|
||||
sys_sem_signal(*sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
main_thread(void *arg)
|
||||
{
|
||||
struct ip_addr ipaddr, netmask, gw;
|
||||
sys_sem_t sem;
|
||||
|
||||
|
||||
IP4_ADDR(&gw, 192,168,1,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,1,2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
netif_set_default(netif_add(&ipaddr, &netmask, &gw, unixif_init_client,
|
||||
tcpip_input));
|
||||
/* netif_set_default(netif_add(&ipaddr, &netmask, &gw, sioslipif_init1,
|
||||
tcpip_input)); */
|
||||
|
||||
|
||||
sem = sys_sem_new(0);
|
||||
tcpip_init(tcpip_init_done, &sem);
|
||||
sys_sem_wait(sem);
|
||||
sys_sem_free(sem);
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
tcpecho_init();
|
||||
shell_init();
|
||||
httpd_init();
|
||||
udpecho_init();
|
||||
|
||||
printf("Applications started.\n");
|
||||
|
||||
sys_timeout(5000, tcp_timeout, NULL);
|
||||
|
||||
#ifdef MEM_PERF
|
||||
mem_perf_init("/tmp/memstats.client");
|
||||
#endif /* MEM_PERF */
|
||||
|
||||
sem = sys_sem_new(0);
|
||||
sys_sem_wait(sem);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef PERF
|
||||
perf_init("/tmp/client.perf");
|
||||
#endif /* PERF */
|
||||
#ifdef STATS
|
||||
stats_init();
|
||||
#endif /* STATS */
|
||||
sys_init();
|
||||
mem_init();
|
||||
memp_init();
|
||||
pbuf_init();
|
||||
|
||||
tcpdump_init();
|
||||
|
||||
|
||||
printf("System initialized.\n");
|
||||
|
||||
sys_thread_new((void *)(main_thread), NULL);
|
||||
pause();
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
|
||||
#include "netif/tapif.h"
|
||||
|
||||
#include "netif/unixif.h"
|
||||
#include "netif/dropif.h"
|
||||
|
||||
#include "netif/loopif.h"
|
||||
|
||||
#include "netif/tcpdump.h"
|
||||
|
||||
#include "netif/sioslipif.h"
|
||||
|
||||
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "arch/perf.h"
|
||||
|
||||
#include "httpd.h"
|
||||
#include "udpecho.h"
|
||||
#include "tcpecho.h"
|
||||
#include "shell.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcp_timeout(void *data)
|
||||
{
|
||||
#if TCP_DEBUG
|
||||
tcp_debug_print_pcbs();
|
||||
#endif /* TCP_DEBUG */
|
||||
sys_timeout(5000, tcp_timeout, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tcpip_init_done(void *arg)
|
||||
{
|
||||
sys_sem_t *sem;
|
||||
sem = arg;
|
||||
sys_sem_signal(*sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
main_thread(void *arg)
|
||||
{
|
||||
struct ip_addr ipaddr, netmask, gw;
|
||||
sys_sem_t sem;
|
||||
|
||||
|
||||
IP4_ADDR(&gw, 192,168,0,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,0,2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
|
||||
netif_set_default(netif_add(&ipaddr, &netmask, &gw, tapif_init,
|
||||
tcpip_input));
|
||||
|
||||
IP4_ADDR(&gw, 192,168,1,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,1,1);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
netif_set_default(netif_add(&ipaddr, &netmask, &gw, unixif_init_server,
|
||||
tcpip_input));
|
||||
|
||||
system("route add 192.168.1.1 192.168.0.2");
|
||||
system("route add 192.168.1.2 192.168.0.2");
|
||||
|
||||
|
||||
/*netif_set_default(netif_add(&ipaddr, &netmask, &gw, sioslipif_init1,
|
||||
tcpip_input)); */
|
||||
|
||||
|
||||
sem = sys_sem_new(0);
|
||||
tcpip_init(tcpip_init_done, &sem);
|
||||
sys_sem_wait(sem);
|
||||
sys_sem_free(sem);
|
||||
printf("TCP/IP initialized.\n");
|
||||
|
||||
tcpecho_init();
|
||||
shell_init();
|
||||
httpd_init();
|
||||
udpecho_init();
|
||||
|
||||
printf("Applications started.\n");
|
||||
|
||||
sys_timeout(5000, tcp_timeout, NULL);
|
||||
|
||||
#ifdef MEM_PERF
|
||||
mem_perf_init("/tmp/memstats.client");
|
||||
#endif /* MEM_PERF */
|
||||
sem = sys_sem_new(0);
|
||||
sys_sem_wait(sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef PERF
|
||||
perf_init("/tmp/client.perf");
|
||||
#endif /* PERF */
|
||||
#ifdef STATS
|
||||
stats_init();
|
||||
#endif /* STATS */
|
||||
sys_init();
|
||||
mem_init();
|
||||
memp_init();
|
||||
pbuf_init();
|
||||
|
||||
tcpdump_init();
|
||||
|
||||
|
||||
printf("System initialized.\n");
|
||||
|
||||
sys_thread_new((void *)(main_thread), NULL);
|
||||
pause();
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
12
src/FILES
12
src/FILES
@@ -1,13 +1,13 @@
|
||||
api/ - The code for the API.
|
||||
api/ - The code for the high-level wrapper API. Not needed if
|
||||
you use the lowel-level call-back/raw API.
|
||||
|
||||
arch/ - Architectural specific files are kept here.
|
||||
core/ - The core of the TPC/IP stack; protocol implementations,
|
||||
memory and buffer management, and the low-level raw API.
|
||||
|
||||
core/ - The core files including protocol implementations, memory
|
||||
and buffer management etc.
|
||||
|
||||
include/ - lwIP include files.
|
||||
|
||||
netif/ - Generic network interface device drivers are kept here.
|
||||
netif/ - Generic network interface device drivers are kept here,
|
||||
as well as the ARP module.
|
||||
|
||||
For more information on the various subdirectories, check the FILES
|
||||
file in each directory.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1380
src/api/api_msg.c
1380
src/api/api_msg.c
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,11 @@
|
||||
/**
|
||||
* @file
|
||||
* Error Management module
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -34,26 +40,35 @@
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
|
||||
static char *err_strerr[] = {"Ok.",
|
||||
"Out of memory error.",
|
||||
"Buffer error.",
|
||||
"Connection aborted.",
|
||||
"Connection reset.",
|
||||
"Connection closed.",
|
||||
"Not connected.",
|
||||
"Illegal value.",
|
||||
"Illegal argument.",
|
||||
"Routing problem.",
|
||||
"Address in use."
|
||||
static const char *err_strerr[] = {
|
||||
"Ok.", /* ERR_OK 0 */
|
||||
"Out of memory error.", /* ERR_MEM -1 */
|
||||
"Buffer error.", /* ERR_BUF -2 */
|
||||
"Timeout.", /* ERR_TIMEOUT -3 */
|
||||
"Routing problem.", /* ERR_RTE -4 */
|
||||
"Connection aborted.", /* ERR_ABRT -5 */
|
||||
"Connection reset.", /* ERR_RST -6 */
|
||||
"Connection closed.", /* ERR_CLSD -7 */
|
||||
"Not connected.", /* ERR_CONN -8 */
|
||||
"Illegal value.", /* ERR_VAL -9 */
|
||||
"Illegal argument.", /* ERR_ARG -10 */
|
||||
"Address in use.", /* ERR_USE -11 */
|
||||
"Low-level netif error.", /* ERR_IF -12 */
|
||||
"Already connected.", /* ERR_ISCONN -13 */
|
||||
"Operation in progress." /* ERR_INPROGRESS -14 */
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
char *
|
||||
/**
|
||||
* Convert an lwip internal error to a string representation.
|
||||
*
|
||||
* @param err an lwip internal err_t
|
||||
* @return a string representation for err
|
||||
*/
|
||||
const char *
|
||||
lwip_strerr(err_t err)
|
||||
{
|
||||
return err_strerr[-err];
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
235
src/api/netbuf.c
Normal file
235
src/api/netbuf.c
Normal file
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* @file
|
||||
* Network buffer management
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/netbuf.h"
|
||||
#include "lwip/memp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Create (allocate) and initialize a new netbuf.
|
||||
* The netbuf doesn't yet contain a packet buffer!
|
||||
*
|
||||
* @return a pointer to a new netbuf
|
||||
* NULL on lack of memory
|
||||
*/
|
||||
struct
|
||||
netbuf *netbuf_new(void)
|
||||
{
|
||||
struct netbuf *buf;
|
||||
|
||||
buf = memp_malloc(MEMP_NETBUF);
|
||||
if (buf != NULL) {
|
||||
buf->p = NULL;
|
||||
buf->ptr = NULL;
|
||||
buf->addr = NULL;
|
||||
return buf;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deallocate a netbuf allocated by netbuf_new().
|
||||
*
|
||||
* @param buf pointer to a netbuf allocated by netbuf_new()
|
||||
*/
|
||||
void
|
||||
netbuf_delete(struct netbuf *buf)
|
||||
{
|
||||
if (buf != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
buf->p = buf->ptr = NULL;
|
||||
}
|
||||
memp_free(MEMP_NETBUF, buf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate memory for a packet buffer for a given netbuf.
|
||||
*
|
||||
* @param buf the netbuf for which to allocate a packet buffer
|
||||
* @param size the size of the packet buffer to allocate
|
||||
* @return pointer to the allocated memory
|
||||
* NULL if no memory could be allocated
|
||||
*/
|
||||
void *
|
||||
netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
{
|
||||
LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;);
|
||||
|
||||
/* Deallocate any previously allocated memory. */
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
|
||||
if (buf->p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
LWIP_ASSERT("check that first pbuf can hold size",
|
||||
(buf->p->len >= size));
|
||||
buf->ptr = buf->p;
|
||||
return buf->p->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the packet buffer included in a netbuf
|
||||
*
|
||||
* @param buf pointer to the netbuf which contains the packet buffer to free
|
||||
*/
|
||||
void
|
||||
netbuf_free(struct netbuf *buf)
|
||||
{
|
||||
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = buf->ptr = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let a netbuf reference existing (non-volatile) data.
|
||||
*
|
||||
* @param buf netbuf which should reference the data
|
||||
* @param dataptr pointer to the data to reference
|
||||
* @param size size of the data
|
||||
* @return ERR_OK if data is referenced
|
||||
* ERR_MEM if data couldn't be referenced due to lack of memory
|
||||
*/
|
||||
err_t
|
||||
netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size)
|
||||
{
|
||||
LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;);
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
|
||||
if (buf->p == NULL) {
|
||||
buf->ptr = NULL;
|
||||
return ERR_MEM;
|
||||
}
|
||||
buf->p->payload = (void*)dataptr;
|
||||
buf->p->len = buf->p->tot_len = size;
|
||||
buf->ptr = buf->p;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chain one netbuf to another (@see pbuf_chain)
|
||||
*
|
||||
* @param head the first netbuf
|
||||
* @param tail netbuf to chain after head, freed by this function, may not be reference after returning
|
||||
*/
|
||||
void
|
||||
netbuf_chain(struct netbuf *head, struct netbuf *tail)
|
||||
{
|
||||
LWIP_ERROR("netbuf_ref: invalid head", (head != NULL), return;);
|
||||
LWIP_ERROR("netbuf_chain: invalid tail", (tail != NULL), return;);
|
||||
pbuf_cat(head->p, tail->p);
|
||||
head->ptr = head->p;
|
||||
memp_free(MEMP_NETBUF, tail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data pointer and length of the data inside a netbuf.
|
||||
*
|
||||
* @param buf netbuf to get the data from
|
||||
* @param dataptr pointer to a void pointer where to store the data pointer
|
||||
* @param len pointer to an u16_t where the length of the data is stored
|
||||
* @return ERR_OK if the information was retreived,
|
||||
* ERR_BUF on error.
|
||||
*/
|
||||
err_t
|
||||
netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
{
|
||||
LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;);
|
||||
LWIP_ERROR("netbuf_data: invalid dataptr", (dataptr != NULL), return ERR_ARG;);
|
||||
LWIP_ERROR("netbuf_data: invalid len", (len != NULL), return ERR_ARG;);
|
||||
|
||||
if (buf->ptr == NULL) {
|
||||
return ERR_BUF;
|
||||
}
|
||||
*dataptr = buf->ptr->payload;
|
||||
*len = buf->ptr->len;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the current data pointer of a packet buffer contained in a netbuf
|
||||
* to the next part.
|
||||
* The packet buffer itself is not modified.
|
||||
*
|
||||
* @param buf the netbuf to modify
|
||||
* @return -1 if there is no next part
|
||||
* 1 if moved to the next part but now there is no next part
|
||||
* 0 if moved to the next part and there are still more parts
|
||||
*/
|
||||
s8_t
|
||||
netbuf_next(struct netbuf *buf)
|
||||
{
|
||||
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return -1;);
|
||||
if (buf->ptr->next == NULL) {
|
||||
return -1;
|
||||
}
|
||||
buf->ptr = buf->ptr->next;
|
||||
if (buf->ptr->next == NULL) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the current data pointer of a packet buffer contained in a netbuf
|
||||
* to the beginning of the packet.
|
||||
* The packet buffer itself is not modified.
|
||||
*
|
||||
* @param buf the netbuf to modify
|
||||
*/
|
||||
void
|
||||
netbuf_first(struct netbuf *buf)
|
||||
{
|
||||
LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;);
|
||||
buf->ptr = buf->p;
|
||||
}
|
||||
|
||||
#endif /* LWIP_NETCONN */
|
||||
353
src/api/netdb.c
Normal file
353
src/api/netdb.c
Normal file
@@ -0,0 +1,353 @@
|
||||
/**
|
||||
* @file
|
||||
* API functions for name resolving
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Simon Goldschmidt
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/netdb.h"
|
||||
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/api.h"
|
||||
|
||||
/** helper struct for gethostbyname_r to access the char* buffer */
|
||||
struct gethostbyname_r_helper {
|
||||
struct ip_addr *addrs;
|
||||
struct ip_addr addr;
|
||||
char *aliases;
|
||||
};
|
||||
|
||||
/** h_errno is exported in netdb.h for access by applications. */
|
||||
#if LWIP_DNS_API_DECLARE_H_ERRNO
|
||||
int h_errno;
|
||||
#endif /* LWIP_DNS_API_DECLARE_H_ERRNO */
|
||||
|
||||
/** define "hostent" variables storage: 0 if we use a static (but unprotected)
|
||||
* set of variables for lwip_gethostbyname, 1 if we use a local storage */
|
||||
#ifndef LWIP_DNS_API_HOSTENT_STORAGE
|
||||
#define LWIP_DNS_API_HOSTENT_STORAGE 0
|
||||
#endif
|
||||
|
||||
/** define "hostent" variables storage */
|
||||
#if LWIP_DNS_API_HOSTENT_STORAGE
|
||||
#define HOSTENT_STORAGE
|
||||
#else
|
||||
#define HOSTENT_STORAGE static
|
||||
#endif /* LWIP_DNS_API_STATIC_HOSTENT */
|
||||
|
||||
/**
|
||||
* Returns an entry containing addresses of address family AF_INET
|
||||
* for the host with name name.
|
||||
* Due to dns_gethostbyname limitations, only one address is returned.
|
||||
*
|
||||
* @param name the hostname to resolve
|
||||
* @return an entry containing addresses of address family AF_INET
|
||||
* for the host with name name
|
||||
*/
|
||||
struct hostent*
|
||||
lwip_gethostbyname(const char *name)
|
||||
{
|
||||
err_t err;
|
||||
struct ip_addr addr;
|
||||
|
||||
/* buffer variables for lwip_gethostbyname() */
|
||||
HOSTENT_STORAGE struct hostent s_hostent;
|
||||
HOSTENT_STORAGE char *s_aliases;
|
||||
HOSTENT_STORAGE struct ip_addr s_hostent_addr;
|
||||
HOSTENT_STORAGE struct ip_addr *s_phostent_addr;
|
||||
|
||||
/* query host IP address */
|
||||
err = netconn_gethostbyname(name, &addr);
|
||||
if (err != ERR_OK) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err));
|
||||
h_errno = HOST_NOT_FOUND;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fill hostent */
|
||||
s_hostent_addr = addr;
|
||||
s_phostent_addr = &s_hostent_addr;
|
||||
s_hostent.h_name = (char*)name;
|
||||
s_hostent.h_aliases = &s_aliases;
|
||||
s_hostent.h_addrtype = AF_INET;
|
||||
s_hostent.h_length = sizeof(struct ip_addr);
|
||||
s_hostent.h_addr_list = (char**)&s_phostent_addr;
|
||||
|
||||
#if DNS_DEBUG
|
||||
/* dump hostent */
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_name == %s\n", s_hostent.h_name));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases == %p\n", s_hostent.h_aliases));
|
||||
if (s_hostent.h_aliases != NULL) {
|
||||
u8_t idx;
|
||||
for ( idx=0; s_hostent.h_aliases[idx]; idx++) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]-> == %p\n", idx, s_hostent.h_aliases[idx]));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_aliases[%i]-> == %s\n", idx, s_hostent.h_aliases[idx]));
|
||||
}
|
||||
}
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addrtype == %d\n", s_hostent.h_addrtype));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_length == %d\n", s_hostent.h_length));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list == %p\n", s_hostent.h_addr_list));
|
||||
if (s_hostent.h_addr_list != NULL) {
|
||||
u8_t idx;
|
||||
for ( idx=0; s_hostent.h_addr_list[idx]; idx++) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i] == %p\n", idx, s_hostent.h_addr_list[idx]));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, inet_ntoa(*((struct in_addr*)(s_hostent.h_addr_list[idx])))));
|
||||
}
|
||||
}
|
||||
#endif /* DNS_DEBUG */
|
||||
|
||||
#if LWIP_DNS_API_HOSTENT_STORAGE
|
||||
/* this function should return the "per-thread" hostent after copy from s_hostent */
|
||||
return sys_thread_hostent(&s_hostent);
|
||||
#else
|
||||
return &s_hostent;
|
||||
#endif /* LWIP_DNS_API_HOSTENT_STORAGE */
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread-safe variant of lwip_gethostbyname: instead of using a static
|
||||
* buffer, this function takes buffer and errno pointers as arguments
|
||||
* and uses these for the result.
|
||||
*
|
||||
* @param name the hostname to resolve
|
||||
* @param ret pre-allocated struct where to store the result
|
||||
* @param buf pre-allocated buffer where to store additional data
|
||||
* @param buflen the size of buf
|
||||
* @param result pointer to a hostent pointer that is set to ret on success
|
||||
* and set to zero on error
|
||||
* @param h_errnop pointer to an int where to store errors (instead of modifying
|
||||
* the global h_errno)
|
||||
* @return 0 on success, non-zero on error, additional error information
|
||||
* is stored in *h_errnop instead of h_errno to be thread-safe
|
||||
*/
|
||||
int
|
||||
lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
|
||||
size_t buflen, struct hostent **result, int *h_errnop)
|
||||
{
|
||||
err_t err;
|
||||
struct gethostbyname_r_helper *h;
|
||||
char *hostname;
|
||||
size_t namelen;
|
||||
int lh_errno;
|
||||
|
||||
if (h_errnop == NULL) {
|
||||
/* ensure h_errnop is never NULL */
|
||||
h_errnop = &lh_errno;
|
||||
}
|
||||
|
||||
if (result == NULL) {
|
||||
/* not all arguments given */
|
||||
*h_errnop = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
/* first thing to do: set *result to nothing */
|
||||
*result = NULL;
|
||||
if ((name == NULL) || (ret == NULL) || (buf == 0)) {
|
||||
/* not all arguments given */
|
||||
*h_errnop = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
namelen = strlen(name);
|
||||
if (buflen < (sizeof(struct gethostbyname_r_helper) + namelen + 1 + (MEM_ALIGNMENT - 1))) {
|
||||
/* buf can't hold the data needed + a copy of name */
|
||||
*h_errnop = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
h = (struct gethostbyname_r_helper*)LWIP_MEM_ALIGN(buf);
|
||||
hostname = ((char*)h) + sizeof(struct gethostbyname_r_helper);
|
||||
|
||||
/* query host IP address */
|
||||
err = netconn_gethostbyname(name, &(h->addr));
|
||||
if (err != ERR_OK) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("lwip_gethostbyname(%s) failed, err=%d\n", name, err));
|
||||
*h_errnop = ENSRNOTFOUND;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* copy the hostname into buf */
|
||||
MEMCPY(hostname, name, namelen);
|
||||
hostname[namelen] = 0;
|
||||
|
||||
/* fill hostent */
|
||||
h->addrs = &(h->addr);
|
||||
h->aliases = NULL;
|
||||
ret->h_name = (char*)hostname;
|
||||
ret->h_aliases = &(h->aliases);
|
||||
ret->h_addrtype = AF_INET;
|
||||
ret->h_length = sizeof(struct ip_addr);
|
||||
ret->h_addr_list = (char**)&(h->addrs);
|
||||
|
||||
/* set result != NULL */
|
||||
*result = ret;
|
||||
|
||||
/* return success */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees one or more addrinfo structures returned by getaddrinfo(), along with
|
||||
* any additional storage associated with those structures. If the ai_next field
|
||||
* of the structure is not null, the entire list of structures is freed.
|
||||
*
|
||||
* @param ai struct addrinfo to free
|
||||
*/
|
||||
void
|
||||
lwip_freeaddrinfo(struct addrinfo *ai)
|
||||
{
|
||||
struct addrinfo *next;
|
||||
|
||||
while (ai != NULL) {
|
||||
if (ai->ai_addr != NULL) {
|
||||
mem_free(ai->ai_addr);
|
||||
}
|
||||
if (ai->ai_canonname != NULL) {
|
||||
mem_free(ai->ai_canonname);
|
||||
}
|
||||
next = ai->ai_next;
|
||||
mem_free(ai);
|
||||
ai = next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the name of a service location (for example, a host name) and/or
|
||||
* a service name and returns a set of socket addresses and associated
|
||||
* information to be used in creating a socket with which to address the
|
||||
* specified service.
|
||||
* Memory for the result is allocated internally and must be freed by calling
|
||||
* lwip_freeaddrinfo()!
|
||||
*
|
||||
* Due to a limitation in dns_gethostbyname, only the first address of a
|
||||
* host is returned.
|
||||
* Also, service names are not supported (only port numbers)!
|
||||
*
|
||||
* @param nodename descriptive name or address string of the host
|
||||
* (may be NULL -> local address)
|
||||
* @param servname port number as string of NULL
|
||||
* @param hints structure containing input values that set socktype and protocol
|
||||
* @param res pointer to a pointer where to store the result (set to NULL on failure)
|
||||
* @return 0 on success, non-zero on failure
|
||||
*/
|
||||
int
|
||||
lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
const struct addrinfo *hints, struct addrinfo **res)
|
||||
{
|
||||
err_t err;
|
||||
struct ip_addr addr;
|
||||
struct addrinfo *ai;
|
||||
struct sockaddr_in *sa = NULL;
|
||||
int port_nr = 0;
|
||||
|
||||
if (res == NULL) {
|
||||
return EAI_FAIL;
|
||||
}
|
||||
*res = NULL;
|
||||
if ((nodename == NULL) && (servname == NULL)) {
|
||||
return EAI_NONAME;
|
||||
}
|
||||
|
||||
if (servname != NULL) {
|
||||
/* service name specified: convert to port number
|
||||
* @todo?: currently, only ASCII integers (port numbers) are supported! */
|
||||
port_nr = atoi(servname);
|
||||
if ((port_nr <= 0) || (port_nr > 0xffff)) {
|
||||
return EAI_SERVICE;
|
||||
}
|
||||
}
|
||||
|
||||
if (nodename != NULL) {
|
||||
/* service location specified, try to resolve */
|
||||
err = netconn_gethostbyname(nodename, &addr);
|
||||
if (err != ERR_OK) {
|
||||
return EAI_FAIL;
|
||||
}
|
||||
} else {
|
||||
/* service location specified, use loopback address */
|
||||
addr.addr = INADDR_LOOPBACK;
|
||||
}
|
||||
|
||||
ai = mem_malloc(sizeof(struct addrinfo));
|
||||
if (ai == NULL) {
|
||||
goto memerr;
|
||||
}
|
||||
memset(ai, 0, sizeof(struct addrinfo));
|
||||
sa = mem_malloc(sizeof(struct sockaddr_in));
|
||||
if (sa == NULL) {
|
||||
goto memerr;
|
||||
}
|
||||
memset(sa, 0, sizeof(struct sockaddr_in));
|
||||
/* set up sockaddr */
|
||||
sa->sin_addr.s_addr = addr.addr;
|
||||
sa->sin_family = AF_INET;
|
||||
sa->sin_len = sizeof(struct sockaddr_in);
|
||||
sa->sin_port = htons(port_nr);
|
||||
|
||||
/* set up addrinfo */
|
||||
ai->ai_family = AF_INET;
|
||||
if (hints != NULL) {
|
||||
/* copy socktype & protocol from hints if specified */
|
||||
ai->ai_socktype = hints->ai_socktype;
|
||||
ai->ai_protocol = hints->ai_protocol;
|
||||
}
|
||||
if (nodename != NULL) {
|
||||
/* copy nodename to canonname if specified */
|
||||
size_t namelen = strlen(nodename);
|
||||
LWIP_ASSERT("namelen is too long", (namelen + 1) <= (mem_size_t)-1);
|
||||
ai->ai_canonname = mem_malloc((mem_size_t)(namelen + 1));
|
||||
if (ai->ai_canonname == NULL) {
|
||||
goto memerr;
|
||||
}
|
||||
MEMCPY(ai->ai_canonname, nodename, namelen);
|
||||
ai->ai_canonname[namelen] = 0;
|
||||
}
|
||||
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
||||
ai->ai_addr = (struct sockaddr*)sa;
|
||||
|
||||
*res = ai;
|
||||
|
||||
return 0;
|
||||
memerr:
|
||||
if (ai != NULL) {
|
||||
mem_free(ai);
|
||||
}
|
||||
if (sa != NULL) {
|
||||
mem_free(sa);
|
||||
}
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
#endif /* LWIP_DNS && LWIP_SOCKET */
|
||||
126
src/api/netifapi.c
Normal file
126
src/api/netifapi.c
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @file
|
||||
* Network Interface Sequential API module
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/netifapi.h"
|
||||
#include "lwip/tcpip.h"
|
||||
|
||||
/**
|
||||
* Call netif_add() inside the tcpip_thread context.
|
||||
*/
|
||||
void
|
||||
do_netifapi_netif_add( struct netifapi_msg_msg *msg)
|
||||
{
|
||||
if (!netif_add( msg->netif,
|
||||
msg->msg.add.ipaddr,
|
||||
msg->msg.add.netmask,
|
||||
msg->msg.add.gw,
|
||||
msg->msg.add.state,
|
||||
msg->msg.add.init,
|
||||
msg->msg.add.input)) {
|
||||
msg->err = ERR_IF;
|
||||
} else {
|
||||
msg->err = ERR_OK;
|
||||
}
|
||||
TCPIP_NETIFAPI_ACK(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
|
||||
* tcpip_thread context.
|
||||
*/
|
||||
void
|
||||
do_netifapi_netif_common( struct netifapi_msg_msg *msg)
|
||||
{
|
||||
if (msg->msg.common.errtfunc!=NULL) {
|
||||
msg->err =
|
||||
msg->msg.common.errtfunc(msg->netif);
|
||||
} else {
|
||||
msg->err = ERR_OK;
|
||||
msg->msg.common.voidfunc(msg->netif);
|
||||
}
|
||||
TCPIP_NETIFAPI_ACK(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call netif_add() in a thread-safe way by running that function inside the
|
||||
* tcpip_thread context.
|
||||
*
|
||||
* @note for params @see netif_add()
|
||||
*/
|
||||
err_t
|
||||
netifapi_netif_add(struct netif *netif,
|
||||
struct ip_addr *ipaddr,
|
||||
struct ip_addr *netmask,
|
||||
struct ip_addr *gw,
|
||||
void *state,
|
||||
err_t (* init)(struct netif *netif),
|
||||
err_t (* input)(struct pbuf *p, struct netif *netif))
|
||||
{
|
||||
struct netifapi_msg msg;
|
||||
msg.function = do_netifapi_netif_add;
|
||||
msg.msg.netif = netif;
|
||||
msg.msg.msg.add.ipaddr = ipaddr;
|
||||
msg.msg.msg.add.netmask = netmask;
|
||||
msg.msg.msg.add.gw = gw;
|
||||
msg.msg.msg.add.state = state;
|
||||
msg.msg.msg.add.init = init;
|
||||
msg.msg.msg.add.input = input;
|
||||
TCPIP_NETIFAPI(&msg);
|
||||
return msg.msg.err;
|
||||
}
|
||||
|
||||
/**
|
||||
* call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
|
||||
* way by running that function inside the tcpip_thread context.
|
||||
*
|
||||
* @note use only for functions where there is only "netif" parameter.
|
||||
*/
|
||||
err_t
|
||||
netifapi_netif_common( struct netif *netif,
|
||||
void (* voidfunc)(struct netif *netif),
|
||||
err_t (* errtfunc)(struct netif *netif) )
|
||||
{
|
||||
struct netifapi_msg msg;
|
||||
msg.function = do_netifapi_netif_common;
|
||||
msg.msg.netif = netif;
|
||||
msg.msg.msg.common.voidfunc = voidfunc;
|
||||
msg.msg.msg.common.errtfunc = errtfunc;
|
||||
TCPIP_NETIFAPI(&msg);
|
||||
return msg.msg.err;
|
||||
}
|
||||
|
||||
#endif /* LWIP_NETIF_API */
|
||||
2029
src/api/sockets.c
2029
src/api/sockets.c
File diff suppressed because it is too large
Load Diff
597
src/api/tcpip.c
597
src/api/tcpip.c
@@ -1,8 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
* Sequential API Main thread module
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@@ -11,127 +17,580 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/ip_frag.h"
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/init.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "netif/ppp_oe.h"
|
||||
|
||||
static void (* tcpip_init_done)(void *arg) = NULL;
|
||||
/* global variables */
|
||||
static void (* tcpip_init_done)(void *arg);
|
||||
static void *tcpip_init_done_arg;
|
||||
static sys_mbox_t mbox;
|
||||
static sys_mbox_t mbox = SYS_MBOX_NULL;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/** The global semaphore to lock the stack. */
|
||||
sys_sem_t lock_tcpip_core;
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
#if LWIP_TCP
|
||||
/* global variable that shows if the tcp timer is currently scheduled or not */
|
||||
static int tcpip_tcp_timer_active;
|
||||
|
||||
/**
|
||||
* Timer callback function that calls tcp_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
tcpip_tcp_timer(void *arg)
|
||||
{
|
||||
tcp_tmr();
|
||||
sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
|
||||
/* call TCP timer handler */
|
||||
tcp_tmr();
|
||||
/* timer still needed? */
|
||||
if (tcp_active_pcbs || tcp_tw_pcbs) {
|
||||
/* restart timer */
|
||||
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
||||
} else {
|
||||
/* disable timer */
|
||||
tcpip_tcp_timer_active = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if !NO_SYS
|
||||
/**
|
||||
* Called from TCP_REG when registering a new PCB:
|
||||
* the reason is to have the TCP timer only running when
|
||||
* there are active (or time-wait) PCBs.
|
||||
*/
|
||||
void
|
||||
tcp_timer_needed(void)
|
||||
{
|
||||
/* timer is off but needed again? */
|
||||
if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) {
|
||||
/* enable and start timer */
|
||||
tcpip_tcp_timer_active = 1;
|
||||
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
||||
}
|
||||
}
|
||||
#endif /* !NO_SYS */
|
||||
#endif /* LWIP_TCP */
|
||||
|
||||
#if IP_REASSEMBLY
|
||||
/**
|
||||
* Timer callback function that calls ip_reass_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
ip_reass_timer(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: ip_reass_tmr()\n"));
|
||||
ip_reass_tmr();
|
||||
sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL);
|
||||
}
|
||||
#endif /* IP_REASSEMBLY */
|
||||
|
||||
#if LWIP_ARP
|
||||
/**
|
||||
* Timer callback function that calls etharp_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
arp_timer(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: etharp_tmr()\n"));
|
||||
etharp_tmr();
|
||||
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
|
||||
}
|
||||
#endif /* LWIP_ARP */
|
||||
|
||||
#if LWIP_DHCP
|
||||
/**
|
||||
* Timer callback function that calls dhcp_coarse_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
dhcp_timer_coarse(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: dhcp_coarse_tmr()\n"));
|
||||
dhcp_coarse_tmr();
|
||||
sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Timer callback function that calls dhcp_fine_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
dhcp_timer_fine(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: dhcp_fine_tmr()\n"));
|
||||
dhcp_fine_tmr();
|
||||
sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL);
|
||||
}
|
||||
#endif /* LWIP_DHCP */
|
||||
|
||||
#if LWIP_AUTOIP
|
||||
/**
|
||||
* Timer callback function that calls autoip_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
autoip_timer(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: autoip_tmr()\n"));
|
||||
autoip_tmr();
|
||||
sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL);
|
||||
}
|
||||
#endif /* LWIP_AUTOIP */
|
||||
|
||||
#if LWIP_IGMP
|
||||
/**
|
||||
* Timer callback function that calls igmp_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
igmp_timer(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: igmp_tmr()\n"));
|
||||
igmp_tmr();
|
||||
sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL);
|
||||
}
|
||||
#endif /* LWIP_IGMP */
|
||||
|
||||
#if LWIP_DNS
|
||||
/**
|
||||
* Timer callback function that calls dns_tmr() and reschedules itself.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
dns_timer(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: dns_tmr()\n"));
|
||||
dns_tmr();
|
||||
sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL);
|
||||
}
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
/**
|
||||
* The main lwIP thread. This thread has exclusive access to lwIP core functions
|
||||
* (unless access to them is not locked). Other threads communicate with this
|
||||
* thread using message boxes.
|
||||
*
|
||||
* It also starts all the timers to make sure they are running in the right
|
||||
* thread context.
|
||||
*
|
||||
* @param arg unused argument
|
||||
*/
|
||||
static void
|
||||
tcpip_thread(void *arg)
|
||||
{
|
||||
struct tcpip_msg *msg;
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
|
||||
ip_init();
|
||||
udp_init();
|
||||
tcp_init();
|
||||
#if IP_REASSEMBLY
|
||||
sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL);
|
||||
#endif /* IP_REASSEMBLY */
|
||||
#if LWIP_ARP
|
||||
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
|
||||
#endif /* LWIP_ARP */
|
||||
#if LWIP_DHCP
|
||||
sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL);
|
||||
sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL);
|
||||
#endif /* LWIP_DHCP */
|
||||
#if LWIP_AUTOIP
|
||||
sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL);
|
||||
#endif /* LWIP_AUTOIP */
|
||||
#if LWIP_IGMP
|
||||
sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL);
|
||||
#endif /* LWIP_IGMP */
|
||||
#if LWIP_DNS
|
||||
sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL);
|
||||
#endif /* LWIP_DNS */
|
||||
|
||||
sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL);
|
||||
|
||||
if(tcpip_init_done != NULL) {
|
||||
if (tcpip_init_done != NULL) {
|
||||
tcpip_init_done(tcpip_init_done_arg);
|
||||
}
|
||||
|
||||
while(1) { /* MAIN Loop */
|
||||
LOCK_TCPIP_CORE();
|
||||
while (1) { /* MAIN Loop */
|
||||
sys_mbox_fetch(mbox, (void *)&msg);
|
||||
switch(msg->type) {
|
||||
switch (msg->type) {
|
||||
#if LWIP_NETCONN
|
||||
case TCPIP_MSG_API:
|
||||
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", msg));
|
||||
api_msg_input(msg->msg.apimsg);
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
|
||||
msg->msg.apimsg->function(&(msg->msg.apimsg->msg));
|
||||
break;
|
||||
case TCPIP_MSG_INPUT:
|
||||
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", msg));
|
||||
ip_input(msg->msg.inp.p, msg->msg.inp.netif);
|
||||
#endif /* LWIP_NETCONN */
|
||||
|
||||
case TCPIP_MSG_INPKT:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg));
|
||||
#if LWIP_ARP
|
||||
if (msg->msg.inp.netif->flags & NETIF_FLAG_ETHARP) {
|
||||
ethernet_input(msg->msg.inp.p, msg->msg.inp.netif);
|
||||
} else
|
||||
#endif /* LWIP_ARP */
|
||||
{ ip_input(msg->msg.inp.p, msg->msg.inp.netif);
|
||||
}
|
||||
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
|
||||
break;
|
||||
|
||||
#if LWIP_NETIF_API
|
||||
case TCPIP_MSG_NETIFAPI:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: Netif API message %p\n", (void *)msg));
|
||||
msg->msg.netifapimsg->function(&(msg->msg.netifapimsg->msg));
|
||||
break;
|
||||
#endif /* LWIP_NETIF_API */
|
||||
|
||||
case TCPIP_MSG_CALLBACK:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg));
|
||||
msg->msg.cb.f(msg->msg.cb.ctx);
|
||||
memp_free(MEMP_TCPIP_MSG_API, msg);
|
||||
break;
|
||||
|
||||
case TCPIP_MSG_TIMEOUT:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: TIMEOUT %p\n", (void *)msg));
|
||||
sys_timeout(msg->msg.tmo.msecs, msg->msg.tmo.h, msg->msg.tmo.arg);
|
||||
memp_free(MEMP_TCPIP_MSG_API, msg);
|
||||
break;
|
||||
case TCPIP_MSG_UNTIMEOUT:
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: UNTIMEOUT %p\n", (void *)msg));
|
||||
sys_untimeout(msg->msg.tmo.h, msg->msg.tmo.arg);
|
||||
memp_free(MEMP_TCPIP_MSG_API, msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
memp_freep(MEMP_TCPIP_MSG, msg);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Pass a received packet to tcpip_thread for input processing
|
||||
*
|
||||
* @param p the received packet, p->payload pointing to the Ethernet header or
|
||||
* to an IP header (if netif doesn't got NETIF_FLAG_ETHARP flag)
|
||||
* @param inp the network interface on which the packet was received
|
||||
*/
|
||||
err_t
|
||||
tcpip_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
||||
if(msg == NULL) {
|
||||
pbuf_free(p);
|
||||
return ERR_MEM;
|
||||
|
||||
if (mbox != SYS_MBOX_NULL) {
|
||||
msg = memp_malloc(MEMP_TCPIP_MSG_INPKT);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
msg->type = TCPIP_MSG_INPKT;
|
||||
msg->msg.inp.p = p;
|
||||
msg->msg.inp.netif = inp;
|
||||
if (sys_mbox_trypost(mbox, msg) != ERR_OK) {
|
||||
memp_free(MEMP_TCPIP_MSG_INPKT, msg);
|
||||
return ERR_MEM;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
msg->type = TCPIP_MSG_INPUT;
|
||||
msg->msg.inp.p = p;
|
||||
msg->msg.inp.netif = inp;
|
||||
sys_mbox_post(mbox, msg);
|
||||
return ERR_OK;
|
||||
return ERR_VAL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
tcpip_apimsg(struct api_msg *apimsg)
|
||||
|
||||
/**
|
||||
* Call a specific function in the thread context of
|
||||
* tcpip_thread for easy access synchronization.
|
||||
* A function called in that way may access lwIP core code
|
||||
* without fearing concurrent access.
|
||||
*
|
||||
* @param f the function to call
|
||||
* @param ctx parameter passed to f
|
||||
* @param block 1 to block until the request is posted, 0 to non-blocking mode
|
||||
* @return ERR_OK if the function was called, another err_t if not
|
||||
*/
|
||||
err_t
|
||||
tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block)
|
||||
{
|
||||
struct tcpip_msg *msg;
|
||||
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
||||
if(msg == NULL) {
|
||||
memp_free(MEMP_API_MSG, apimsg);
|
||||
return;
|
||||
|
||||
if (mbox != SYS_MBOX_NULL) {
|
||||
msg = memp_malloc(MEMP_TCPIP_MSG_API);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
msg->type = TCPIP_MSG_CALLBACK;
|
||||
msg->msg.cb.f = f;
|
||||
msg->msg.cb.ctx = ctx;
|
||||
if (block) {
|
||||
sys_mbox_post(mbox, msg);
|
||||
} else {
|
||||
if (sys_mbox_trypost(mbox, msg) != ERR_OK) {
|
||||
memp_free(MEMP_TCPIP_MSG_API, msg);
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
msg->type = TCPIP_MSG_API;
|
||||
msg->msg.apimsg = apimsg;
|
||||
sys_mbox_post(mbox, msg);
|
||||
return ERR_VAL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* call sys_timeout in tcpip_thread
|
||||
*
|
||||
* @param msec time in miliseconds for timeout
|
||||
* @param h function to be called on timeout
|
||||
* @param arg argument to pass to timeout function h
|
||||
* @return ERR_MEM on memory error, ERR_OK otherwise
|
||||
*/
|
||||
err_t
|
||||
tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
||||
{
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (mbox != SYS_MBOX_NULL) {
|
||||
msg = memp_malloc(MEMP_TCPIP_MSG_API);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
msg->type = TCPIP_MSG_TIMEOUT;
|
||||
msg->msg.tmo.msecs = msecs;
|
||||
msg->msg.tmo.h = h;
|
||||
msg->msg.tmo.arg = arg;
|
||||
sys_mbox_post(mbox, msg);
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* call sys_untimeout in tcpip_thread
|
||||
*
|
||||
* @param msec time in miliseconds for timeout
|
||||
* @param h function to be called on timeout
|
||||
* @param arg argument to pass to timeout function h
|
||||
* @return ERR_MEM on memory error, ERR_OK otherwise
|
||||
*/
|
||||
err_t
|
||||
tcpip_untimeout(sys_timeout_handler h, void *arg)
|
||||
{
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (mbox != SYS_MBOX_NULL) {
|
||||
msg = memp_malloc(MEMP_TCPIP_MSG_API);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
msg->type = TCPIP_MSG_UNTIMEOUT;
|
||||
msg->msg.tmo.h = h;
|
||||
msg->msg.tmo.arg = arg;
|
||||
sys_mbox_post(mbox, msg);
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#if LWIP_NETCONN
|
||||
/**
|
||||
* Call the lower part of a netconn_* function
|
||||
* This function is then running in the thread context
|
||||
* of tcpip_thread and has exclusive access to lwIP core code.
|
||||
*
|
||||
* @param apimsg a struct containing the function to call and its parameters
|
||||
* @return ERR_OK if the function was called, another err_t if not
|
||||
*/
|
||||
err_t
|
||||
tcpip_apimsg(struct api_msg *apimsg)
|
||||
{
|
||||
struct tcpip_msg msg;
|
||||
|
||||
if (mbox != SYS_MBOX_NULL) {
|
||||
msg.type = TCPIP_MSG_API;
|
||||
msg.msg.apimsg = apimsg;
|
||||
sys_mbox_post(mbox, &msg);
|
||||
sys_arch_sem_wait(apimsg->msg.conn->op_completed, 0);
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
/**
|
||||
* Call the lower part of a netconn_* function
|
||||
* This function has exclusive access to lwIP core code by locking it
|
||||
* before the function is called.
|
||||
*
|
||||
* @param apimsg a struct containing the function to call and its parameters
|
||||
* @return ERR_OK (only for compatibility fo tcpip_apimsg())
|
||||
*/
|
||||
err_t
|
||||
tcpip_apimsg_lock(struct api_msg *apimsg)
|
||||
{
|
||||
LOCK_TCPIP_CORE();
|
||||
apimsg->function(&(apimsg->msg));
|
||||
UNLOCK_TCPIP_CORE();
|
||||
return ERR_OK;
|
||||
|
||||
}
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
#endif /* LWIP_NETCONN */
|
||||
|
||||
#if LWIP_NETIF_API
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
/**
|
||||
* Much like tcpip_apimsg, but calls the lower part of a netifapi_*
|
||||
* function.
|
||||
*
|
||||
* @param netifapimsg a struct containing the function to call and its parameters
|
||||
* @return error code given back by the function that was called
|
||||
*/
|
||||
err_t
|
||||
tcpip_netifapi(struct netifapi_msg* netifapimsg)
|
||||
{
|
||||
struct tcpip_msg msg;
|
||||
|
||||
if (mbox != SYS_MBOX_NULL) {
|
||||
netifapimsg->msg.sem = sys_sem_new(0);
|
||||
if (netifapimsg->msg.sem == SYS_SEM_NULL) {
|
||||
netifapimsg->msg.err = ERR_MEM;
|
||||
return netifapimsg->msg.err;
|
||||
}
|
||||
|
||||
msg.type = TCPIP_MSG_NETIFAPI;
|
||||
msg.msg.netifapimsg = netifapimsg;
|
||||
sys_mbox_post(mbox, &msg);
|
||||
sys_sem_wait(netifapimsg->msg.sem);
|
||||
sys_sem_free(netifapimsg->msg.sem);
|
||||
return netifapimsg->msg.err;
|
||||
}
|
||||
return ERR_VAL;
|
||||
}
|
||||
#else /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
/**
|
||||
* Call the lower part of a netifapi_* function
|
||||
* This function has exclusive access to lwIP core code by locking it
|
||||
* before the function is called.
|
||||
*
|
||||
* @param netifapimsg a struct containing the function to call and its parameters
|
||||
* @return ERR_OK (only for compatibility fo tcpip_netifapi())
|
||||
*/
|
||||
err_t
|
||||
tcpip_netifapi_lock(struct netifapi_msg* netifapimsg)
|
||||
{
|
||||
LOCK_TCPIP_CORE();
|
||||
netifapimsg->function(&(netifapimsg->msg));
|
||||
UNLOCK_TCPIP_CORE();
|
||||
return netifapimsg->msg.err;
|
||||
}
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
#endif /* LWIP_NETIF_API */
|
||||
|
||||
/**
|
||||
* Initialize this module:
|
||||
* - initialize all sub modules
|
||||
* - start the tcpip_thread
|
||||
*
|
||||
* @param initfunc a function to call when tcpip_thread is running and finished initializing
|
||||
* @param arg argument to pass to initfunc
|
||||
*/
|
||||
void
|
||||
tcpip_init(void (* initfunc)(void *), void *arg)
|
||||
{
|
||||
lwip_init();
|
||||
|
||||
tcpip_init_done = initfunc;
|
||||
tcpip_init_done_arg = arg;
|
||||
mbox = sys_mbox_new();
|
||||
sys_thread_new((void *)tcpip_thread, NULL);
|
||||
mbox = sys_mbox_new(TCPIP_MBOX_SIZE);
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
lock_tcpip_core = sys_sem_new(1);
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Simple callback function used with tcpip_callback to free a pbuf
|
||||
* (pbuf_free has a wrong signature for tcpip_callback)
|
||||
*
|
||||
* @param p The pbuf (chain) to be dereferenced.
|
||||
*/
|
||||
static void
|
||||
pbuf_free_int(void *p)
|
||||
{
|
||||
struct pbuf *q = p;
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple wrapper function that allows you to free a pbuf from interrupt context.
|
||||
*
|
||||
* @param p The pbuf (chain) to be dereferenced.
|
||||
* @return ERR_OK if callback could be enqueued, an err_t if not
|
||||
*/
|
||||
err_t
|
||||
pbuf_free_callback(struct pbuf *p)
|
||||
{
|
||||
return tcpip_callback_with_block(pbuf_free_int, p, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple wrapper function that allows you to free heap memory from
|
||||
* interrupt context.
|
||||
*
|
||||
* @param m the heap memory to free
|
||||
* @return ERR_OK if callback could be enqueued, an err_t if not
|
||||
*/
|
||||
err_t
|
||||
mem_free_callback(void *m)
|
||||
{
|
||||
return tcpip_callback_with_block(mem_free, m, 0);
|
||||
}
|
||||
|
||||
#endif /* !NO_SYS */
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
The 6502 code is far from complete.
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __CC_H__
|
||||
#define __CC_H__
|
||||
|
||||
typedef unsigned char u8_t;
|
||||
typedef signed char s8_t;
|
||||
typedef unsigned short u16_t;
|
||||
typedef signed short s16_t;
|
||||
typedef unsigned long u32_t;
|
||||
typedef signed long s32_t;
|
||||
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
|
||||
#endif /* __CC_H__ */
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __CPU_H__
|
||||
#define __CPU_H__
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#endif /* __CPU_H__ */
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LIB_H__
|
||||
#define __LIB_H__
|
||||
|
||||
int strlen(const char *str);
|
||||
int strncmp(const char *str1, const char *str2, int len);
|
||||
void bcopy(const void *src, void *dest, int len);
|
||||
void bzero(void *data, int n);
|
||||
|
||||
#endif /* __LIB_H__ */
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __PERF_H__
|
||||
#define __PERF_H__
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
#endif /* __PERF_H__ */
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __SYS_C64_H__
|
||||
#define __SYS_C64_H__
|
||||
|
||||
#define SYS_MBOX_NULL 0
|
||||
|
||||
typedef int sys_sem_t;
|
||||
typedef int sys_mbox_t;
|
||||
typedef int sys_thread_t;
|
||||
|
||||
#endif /* __SYS_C64_H__ */
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <c64.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
struct sys_timeouts timeouts;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_arch_block(u16_t time)
|
||||
{
|
||||
u16_t ticks;
|
||||
|
||||
ticks = time * (CLK_TCK / 1000) + clock();
|
||||
printf("ticks %d\n", ticks);
|
||||
|
||||
while(clock() != ticks);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
sys_mbox_t
|
||||
sys_mbox_new(void)
|
||||
{
|
||||
return SYS_MBOX_NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_mbox_free(sys_mbox_t mbox)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_mbox_post(sys_mbox_t mbox, void *data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout)
|
||||
{
|
||||
sys_arch_block(timeout);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
sys_sem_t
|
||||
sys_sem_new(u8_t count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)
|
||||
{
|
||||
sys_arch_block(timeout);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_sem_signal(sys_sem_t sem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_sem_free(sys_sem_t sem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_init(void)
|
||||
{
|
||||
timeouts.next = NULL;
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct sys_timeouts *
|
||||
sys_arch_timeouts(void)
|
||||
{
|
||||
return &timeouts;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_thread_new(void (* function)(void *arg), void *arg)
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -1,15 +0,0 @@
|
||||
6502/ - Architectural files for the 6502 CPU.
|
||||
|
||||
rtxc/ - Architectural files for the RTXC operating system.
|
||||
|
||||
unix/ - Architectural files for testing on unix-like systems
|
||||
(assuming gcc and pthreads).
|
||||
|
||||
Each subdirectory (may) also include:
|
||||
|
||||
perf.c - Optional file that should be implemented when running
|
||||
performance tests of lwIP.
|
||||
|
||||
sys.c - Implementation of the operating system emulation layer.
|
||||
|
||||
netif/ - Architectural specific network interfaces.
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __CC_H__
|
||||
#define __CC_H__
|
||||
|
||||
typedef unsigned char u8_t;
|
||||
typedef signed char s8_t;
|
||||
typedef unsigned short u16_t;
|
||||
typedef signed short s16_t;
|
||||
typedef unsigned long u32_t;
|
||||
typedef signed long s32_t;
|
||||
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
|
||||
#endif /* __CC_H__ */
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __CPU_H__
|
||||
#define __CPU_H__
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#endif /* __CPU_H__ */
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_INIT_H__
|
||||
#define __ARCH_INIT_H__
|
||||
|
||||
#define TCPIP_INIT_DONE(arg) tcpip_init_done(arg)
|
||||
|
||||
void tcpip_init_done(void *);
|
||||
int wait_for_tcpip_init(void);
|
||||
|
||||
#endif /* __ARCH_INIT_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __LIB_H__
|
||||
#define __LIB_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define bcopy(s, d, l) memcpy(d, s, l)
|
||||
#define bzero(d, l) memset(d, 0, l)
|
||||
|
||||
#endif /* __LIB_H__ */
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __PERF_H__
|
||||
#define __PERF_H__
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
#endif /* __PERF_H__ */
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __SYS_RTXC_H__
|
||||
#define __SYS_RTXC_H__
|
||||
|
||||
#include "rtxcapi.h"
|
||||
|
||||
#define SYS_MBOX_NULL (QUEUE)0
|
||||
#define SYS_SEM_NULL (SEMA)0
|
||||
|
||||
typedef SEMA sys_sem_t;
|
||||
typedef QUEUE sys_mbox_t;
|
||||
typedef TASK sys_thread_t;
|
||||
|
||||
#endif /* __SYS_RTXC_H__ */
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __NETIF_CS8900IF_H__
|
||||
#define __NETIF_CS8900IF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void cs8900if_init(struct netif *);
|
||||
u8_t cs8900if_poll(struct netif *);
|
||||
void cs8900if_input(struct netif *);
|
||||
|
||||
#endif /* __NETIF_CS8900IF_H__ */
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __NETIF_SIOSLIPIF_H__
|
||||
#define __NETIF_SIOSLIPIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void sioslipif_init(struct netif *);
|
||||
|
||||
#endif /* __NETIF_SIOSLIPIF_H__ */
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/* These are generic implementations of various library functions used
|
||||
* throughout the lwIP code. When porting, those should be optimized
|
||||
* for the particular processor architecture, preferably coded in
|
||||
* assembler.
|
||||
*/
|
||||
|
||||
#if 0 /* Define to 1 if these are really needed. */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
bcopy(const void *src, void *dst, unsigned int size)
|
||||
{
|
||||
char *csrc, *cdst;
|
||||
unsigned int i;
|
||||
|
||||
csrc = (char *)src;
|
||||
cdst = dst;
|
||||
|
||||
for(i = 0; i < size; ++i) {
|
||||
cdst[i] = csrc[i];
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
bzero(void *s, int n)
|
||||
{
|
||||
for(--n ;n >= 0; --n) {
|
||||
((char *)s)[n] = 0;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#endif /* 0 */
|
||||
@@ -1 +0,0 @@
|
||||
sioslipif.c - Implementation of the SLIP protocol on top of a serial line.
|
||||
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
#include "lwip/def.h"
|
||||
#include "netif/sioslipif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#define SLIP_END 0300
|
||||
#define SLIP_ESC 0333
|
||||
#define SLIP_ESC_END 0334
|
||||
#define SLIP_ESC_ESC 0335
|
||||
|
||||
/* This variable is used for passing the netif pointer between the
|
||||
threads. */
|
||||
static struct netif *netif_pass;
|
||||
|
||||
static int infd, outfd;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
sio_send(u8_t c)
|
||||
{
|
||||
write(outfd, &c, 1);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
sio_recv(void)
|
||||
{
|
||||
u8_t c;
|
||||
read(infd, &c, 1);
|
||||
return c;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static int
|
||||
sioslipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
||||
{
|
||||
struct pbuf *q;
|
||||
int i;
|
||||
u8_t c;
|
||||
|
||||
/* Send pbuf out on the serial I/O device. */
|
||||
sio_send(SLIP_END);
|
||||
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
for(i = 0; i < q->len; i++) {
|
||||
c = ((u8_t *)q->payload)[i];
|
||||
switch(c) {
|
||||
case SLIP_END:
|
||||
sio_send(SLIP_ESC);
|
||||
sio_send(SLIP_ESC_END);
|
||||
break;
|
||||
case SLIP_ESC:
|
||||
sio_send(SLIP_ESC);
|
||||
sio_send(SLIP_ESC_ESC);
|
||||
break;
|
||||
default:
|
||||
sio_send(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
sio_send(SLIP_END);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct pbuf *
|
||||
sioslipif_input(void)
|
||||
{
|
||||
u8_t c;
|
||||
struct pbuf *p, *q;
|
||||
int recved;
|
||||
int i;
|
||||
|
||||
p = pbuf_alloc(PBUF_LINK, PBUF_MAX_SIZE, PBUF_POOL);
|
||||
q = p;
|
||||
recved = i = 0;
|
||||
|
||||
while(1) {
|
||||
c = sio_recv();
|
||||
switch(c) {
|
||||
case SLIP_END:
|
||||
if(recved > 0) {
|
||||
/* Received whole packet. */
|
||||
pbuf_realloc(p, recved);
|
||||
return p;
|
||||
}
|
||||
break;
|
||||
case SLIP_ESC:
|
||||
c = sio_recv();
|
||||
switch(c) {
|
||||
case SLIP_ESC_END:
|
||||
c = SLIP_END;
|
||||
break;
|
||||
case SLIP_ESC_ESC:
|
||||
c = SLIP_ESC;
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if(recved < p->tot_len && q != NULL) {
|
||||
((u8_t *)q->payload)[i] = c;
|
||||
recved++;
|
||||
i++;
|
||||
if(i >= q->len) {
|
||||
i = 0;
|
||||
q = q->next;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
sioslipif_loop(void)
|
||||
{
|
||||
struct pbuf *p;
|
||||
struct netif *netif;
|
||||
|
||||
netif = netif_pass;
|
||||
while(1) {
|
||||
p = sioslipif_input();
|
||||
netif->input(p, netif);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sioslipif_init(struct netif *netif)
|
||||
{
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 's';
|
||||
netif->name[1] = 'l';
|
||||
netif->output = sioslipif_output;
|
||||
|
||||
netif_pass = netif;
|
||||
sys_thread_new((void *)sioslipif_loop, NULL);
|
||||
/* Do some magic to make it possible to receive data from the serial I/O device. */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "arch/perf.h"
|
||||
|
||||
void
|
||||
perf_init(char *fname)
|
||||
{
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/mem.h"
|
||||
|
||||
#include "rtxcapi.h"
|
||||
#include "csema.h"
|
||||
#include "cclock.h"
|
||||
#include "cqueue.h"
|
||||
#include "cres.h"
|
||||
#include "cpart.h"
|
||||
#include "ctask.h"
|
||||
|
||||
struct timeoutlist {
|
||||
struct sys_timeouts timeouts;
|
||||
TASK pid;
|
||||
};
|
||||
|
||||
#define SYS_THREAD_MAX 2
|
||||
|
||||
static struct timeoutlist timeoutlist[SYS_THREAD_MAX];
|
||||
static u16_t nextthread = 0;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
sys_mbox_t
|
||||
sys_mbox_new(void)
|
||||
{
|
||||
QUEUE mbox;
|
||||
KS_dequeuew(IP_MBOXQ, &mbox);
|
||||
KS_purgequeue(mbox);
|
||||
return mbox;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_mbox_free(sys_mbox_t mbox)
|
||||
{
|
||||
KS_enqueue(IP_MBOXQ, &mbox);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_mbox_post(sys_mbox_t mbox, void *data)
|
||||
{
|
||||
if(KS_enqueue(mbox, &data) != RC_GOOD) {
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
sys_arch_mbox_fetch(sys_mbox_t mbox, void **data, u16_t timeout)
|
||||
{
|
||||
KSRC ret;
|
||||
u16_t wtime = 1;
|
||||
|
||||
if(timeout == 0) {
|
||||
DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: without timeouts\n",KS_inqtask()));
|
||||
KS_dequeuew(mbox, data);
|
||||
|
||||
} else {
|
||||
|
||||
ret = KS_dequeuet(mbox, data, (TICKS)timeout/CLKTICK);
|
||||
if(ret == RC_TIMEOUT) {
|
||||
/* The call timed out, so we return 0. */
|
||||
wtime = 0;
|
||||
} else {
|
||||
/* Calculate time we waited for the message to arrive. */
|
||||
|
||||
/* XXX: we cheat and just pretend that we waited for half the timeout value! */
|
||||
wtime = timeout / 2;
|
||||
|
||||
/* Make sure we don't return 0 here. */
|
||||
if(wtime == 0) {
|
||||
wtime = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return wtime;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
sys_sem_t
|
||||
sys_sem_new(u8_t count)
|
||||
{
|
||||
SEMA sem;
|
||||
KS_dequeuew(IP_SEMQ, &sem);
|
||||
KS_pend(sem);
|
||||
if(count > 0) {
|
||||
KS_signal(sem);
|
||||
}
|
||||
return sem;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
sys_arch_sem_wait(sys_sem_t sem, u16_t timeout)
|
||||
{
|
||||
KSRC ret;
|
||||
u16_t wtime = 1;
|
||||
|
||||
if(timeout == 0) {
|
||||
DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: without timeouts\n",KS_inqtask()));
|
||||
KS_wait(sem);
|
||||
|
||||
} else {
|
||||
ret = KS_waitt(sem, (TICKS)timeout/CLKTICK);
|
||||
if(ret == RC_TIMEOUT) {
|
||||
/* The call timed out, so we return 0. */
|
||||
wtime = 0;
|
||||
} else {
|
||||
/* Calculate time we waited for the message to arrive. */
|
||||
|
||||
/* XXX: we cheat and just pretend that we waited for half the timeout value! */
|
||||
wtime = timeout / 2;
|
||||
|
||||
/* Make sure we don't return 0 here. */
|
||||
if(wtime == 0) {
|
||||
wtime = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return wtime;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_sem_signal(sys_sem_t sem)
|
||||
{
|
||||
KS_signal(sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_sem_free(sys_sem_t sem)
|
||||
{
|
||||
KS_enqueue(IP_SEMQ, &sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_init(void)
|
||||
{
|
||||
/* posta in alla semaforer i IP_SEMQ, posta in alla mboxar i
|
||||
IP_MBOXQ */
|
||||
QUEUE mbox;
|
||||
SEMA sem;
|
||||
|
||||
mbox = IP_Q_01; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_02; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_03; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_04; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_05; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_06; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_07; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_08; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_09; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_10; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_11; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_12; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_13; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_14; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
mbox = IP_Q_15; KS_enqueue(IP_MBOXQ, &mbox);
|
||||
sem = IP_S_01; KS_enqueue(IP_SEMQ, &sem);
|
||||
sem = IP_S_02; KS_enqueue(IP_SEMQ, &sem);
|
||||
sem = IP_S_03; KS_enqueue(IP_SEMQ, &sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct sys_timeouts *
|
||||
sys_arch_timeouts(void)
|
||||
{
|
||||
int i;
|
||||
TASK pid;
|
||||
struct timeoutlist *tl;
|
||||
|
||||
DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: timeoutlist not empty\n",KS_inqtask()));
|
||||
pid = KS_inqtask();
|
||||
for(i = 0; i < nextthread; i++) {
|
||||
tl = &timeoutlist[i];
|
||||
if(tl->pid == pid) {
|
||||
DEBUGF(SYS_DEBUG, ("PID: %d sys_mbox_fetch: corresponding pid found!\n",KS_inqtask()));
|
||||
return &(tl->timeouts);
|
||||
}
|
||||
}
|
||||
|
||||
/* Error! */
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct sys_thread_arg {
|
||||
void (* thread)(void *);
|
||||
void *threadarg;
|
||||
SEMA sem;
|
||||
};
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
sys_thread(void)
|
||||
{
|
||||
struct sys_thread_arg *arg;
|
||||
void (* thread)(void *);
|
||||
void *threadarg;
|
||||
|
||||
arg = KS_inqtask_arg(0);
|
||||
if(arg != NULL) {
|
||||
|
||||
timeoutlist[nextthread].timeouts.next = NULL;
|
||||
timeoutlist[nextthread].pid = KS_inqtask();
|
||||
|
||||
++nextthread;
|
||||
|
||||
thread = arg->thread;
|
||||
threadarg = arg->threadarg;
|
||||
KS_signal(arg->sem);
|
||||
thread(threadarg);
|
||||
}
|
||||
KS_terminate(0);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_thread_new(void (* function)(void *arg), void *arg)
|
||||
{
|
||||
TASK newtask;
|
||||
PRIORITY pri = 2; /* This may have to be changed. */
|
||||
char *stack;
|
||||
int stacksize = 512; /* This may have to be changed. */
|
||||
struct sys_thread_arg threadarg;
|
||||
|
||||
|
||||
newtask = KS_alloc_task();
|
||||
stack = KS_allocw(MAP512);
|
||||
|
||||
KS_deftask(newtask, pri, (char ks_stk *)stack, (size_t)stacksize, (void (*)(void))sys_thread);
|
||||
|
||||
threadarg.thread = function;
|
||||
threadarg.threadarg = arg;
|
||||
threadarg.sem = THRDSYNC;
|
||||
KS_deftask_arg(newtask, &threadarg);
|
||||
KS_execute(newtask);
|
||||
KS_wait(THRDSYNC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_CC_H__
|
||||
#define __ARCH_CC_H__
|
||||
|
||||
typedef unsigned char u8_t;
|
||||
typedef signed char s8_t;
|
||||
/*typedef unsigned short u8_t;
|
||||
typedef signed short s8_t; */
|
||||
typedef unsigned short u16_t;
|
||||
typedef signed short s16_t;
|
||||
typedef unsigned long u32_t;
|
||||
typedef signed long s32_t;
|
||||
|
||||
typedef u32_t mem_ptr_t;
|
||||
|
||||
#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_CPU_H__
|
||||
#define __ARCH_CPU_H__
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif /* BYTE_ORDER */
|
||||
|
||||
#endif /* __ARCH_CPU_H__ */
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_INIT_H__
|
||||
#define __ARCH_INIT_H__
|
||||
|
||||
#define TCPIP_INIT_DONE(arg) sys_sem_signal(*(sys_sem_t *)arg)
|
||||
|
||||
#endif /* __ARCH_INIT_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_LIB_H__
|
||||
#define __ARCH_LIB_H__
|
||||
|
||||
#ifndef _STRING_H_
|
||||
#ifndef _STRING_H
|
||||
int strlen(const char *str);
|
||||
int strncmp(const char *str1, const char *str2, int len);
|
||||
void bcopy(const void *src, void *dest, int len);
|
||||
void bzero(void *data, int n);
|
||||
#endif /* _STRING_H */
|
||||
#endif /* _STRING_H_ */
|
||||
|
||||
#endif /* __ARCH_LIB_H__ */
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_PERF_H__
|
||||
#define __ARCH_PERF_H__
|
||||
|
||||
#include <sys/times.h>
|
||||
|
||||
#ifdef PERF
|
||||
#define PERF_START { \
|
||||
unsigned long __c1l, __c1h, __c2l, __c2h; \
|
||||
__asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h))
|
||||
#define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \
|
||||
perf_print(__c1l, __c1h, __c2l, __c2h, x);}
|
||||
|
||||
/*#define PERF_START do { \
|
||||
struct tms __perf_start, __perf_end; \
|
||||
times(&__perf_start)
|
||||
#define PERF_STOP(x) times(&__perf_end); \
|
||||
perf_print_times(&__perf_start, &__perf_end, x);\
|
||||
} while(0)*/
|
||||
#else /* PERF */
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
#endif /* PERF */
|
||||
|
||||
void perf_print(unsigned long c1l, unsigned long c1h,
|
||||
unsigned long c2l, unsigned long c2h,
|
||||
char *key);
|
||||
|
||||
void perf_print_times(struct tms *start, struct tms *end, char *key);
|
||||
|
||||
void perf_init(char *fname);
|
||||
|
||||
#endif /* __ARCH_PERF_H__ */
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_SYS_ARCH_H__
|
||||
#define __ARCH_SYS_ARCH_H__
|
||||
|
||||
#define SYS_MBOX_NULL NULL
|
||||
#define SYS_SEM_NULL NULL
|
||||
|
||||
struct sys_sem;
|
||||
typedef struct sys_sem * sys_sem_t;
|
||||
|
||||
struct sys_mbox;
|
||||
typedef struct sys_mbox *sys_mbox_t;
|
||||
|
||||
struct sys_thread;
|
||||
typedef struct sys_thread * sys_thread_t;
|
||||
|
||||
#endif /* __ARCH_SYS_ARCH_H__ */
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __PCAPIF_H__
|
||||
#define __PCAPIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void pcapif_init(struct netif *netif);
|
||||
|
||||
#endif /* __PCAPIF_H__ */
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __NETIF_SIOSLIPIF_H__
|
||||
#define __NETIF_SIOSLIPIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void sioslipif_init(struct netif *);
|
||||
|
||||
|
||||
void sioslipif_init1(struct netif *);
|
||||
void sioslipif_init2(struct netif *);
|
||||
|
||||
#endif /* __NETIF_SIOSLIPIF_H__ */
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __TAPIF_H__
|
||||
#define __TAPIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void tapif_init(struct netif *netif);
|
||||
|
||||
#endif /* __TAPIF_H__ */
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
#ifndef __UNIXIF_H__
|
||||
#define __UNIXIF_H__
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
void unixif_init_server(struct netif *netif);
|
||||
void unixif_init_client(struct netif *netif);
|
||||
|
||||
#endif /* __UNIXIF_H__ */
|
||||
@@ -1,310 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "netif/delif.h"
|
||||
|
||||
#ifdef linux
|
||||
#include "netif/tapif.h"
|
||||
#else /* linux */
|
||||
#include "netif/tunif.h"
|
||||
#endif /* linux */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
|
||||
|
||||
#define DELIF_INPUT_DROPRATE 0.1
|
||||
#define DELIF_OUTPUT_DROPRATE 0.1
|
||||
|
||||
#define DELIF_INPUT_DELAY 500 /* Miliseconds. */
|
||||
#define DELIF_OUTPUT_DELAY 500 /* Miliseconds. */
|
||||
|
||||
#define DELIF_TIMEOUT 10
|
||||
|
||||
struct delif {
|
||||
err_t (* input)(struct pbuf *p, struct netif *inp);
|
||||
struct netif *netif;
|
||||
};
|
||||
|
||||
struct delif_pbuf {
|
||||
struct delif_pbuf *next;
|
||||
struct pbuf *p;
|
||||
struct ip_addr *ipaddr;
|
||||
unsigned int time;
|
||||
};
|
||||
|
||||
static struct delif_pbuf *input_list = NULL;
|
||||
static struct delif_pbuf *output_list = NULL;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
delif_input_timeout(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct delif *delif;
|
||||
struct delif_pbuf *dp;
|
||||
unsigned int timeout, now;
|
||||
|
||||
timeout = DELIF_TIMEOUT;
|
||||
|
||||
netif = arg;
|
||||
delif = netif->state;
|
||||
|
||||
|
||||
/* Check if there is anything on the input list. */
|
||||
dp = input_list;
|
||||
while(dp != NULL) {
|
||||
now = sys_now();
|
||||
|
||||
if(dp->time <= now) {
|
||||
delif->input(dp->p, netif);
|
||||
if(dp->next != NULL) {
|
||||
if(dp->next->time > now) {
|
||||
timeout = dp->next->time - now;
|
||||
} else {
|
||||
timeout = 0;
|
||||
}
|
||||
DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout));
|
||||
|
||||
}
|
||||
input_list = dp->next;
|
||||
free(dp);
|
||||
dp = input_list;
|
||||
} else {
|
||||
dp = dp->next;
|
||||
}
|
||||
}
|
||||
|
||||
sys_timeout(timeout, delif_input_timeout, arg);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
delif_output_timeout(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct delif *delif;
|
||||
struct delif_pbuf *dp;
|
||||
unsigned int timeout, now;
|
||||
|
||||
timeout = DELIF_TIMEOUT;
|
||||
|
||||
netif = arg;
|
||||
delif = netif->state;
|
||||
|
||||
/* Check if there is anything on the output list. */
|
||||
dp = output_list;
|
||||
while(dp != NULL) {
|
||||
now = sys_now();
|
||||
if(dp->time <= now) {
|
||||
DEBUGF(DELIF_DEBUG, ("delif_output_timeout: now %u dp->time %u\n",
|
||||
now, dp->time));
|
||||
delif->netif->output(delif->netif, dp->p, dp->ipaddr);
|
||||
if(dp->next != NULL) {
|
||||
if(dp->next->time > now) {
|
||||
timeout = dp->next->time - now;
|
||||
} else {
|
||||
timeout = 0;
|
||||
}
|
||||
DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout));
|
||||
|
||||
}
|
||||
pbuf_free(dp->p);
|
||||
|
||||
output_list = dp->next;
|
||||
free(dp);
|
||||
dp = output_list;
|
||||
} else {
|
||||
dp = dp->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sys_timeout(timeout, delif_output_timeout, arg);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
delif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
||||
{
|
||||
struct delif_pbuf *dp, *np;
|
||||
struct pbuf *q;
|
||||
int i, j;
|
||||
char *data;
|
||||
|
||||
DEBUGF(DELIF_DEBUG, ("delif_output\n"));
|
||||
|
||||
#ifdef DELIF_OUTPUT_DROPRATE
|
||||
if(((double)rand()/(double)RAND_MAX) < DELIF_OUTPUT_DROPRATE) {
|
||||
DEBUGF(DELIF_DEBUG, ("delif_output: Packet dropped\n"));
|
||||
return 0;
|
||||
}
|
||||
#endif /* DELIF_OUTPUT_DROPRATE */
|
||||
|
||||
|
||||
DEBUGF(DELIF_DEBUG, ("delif_output\n"));
|
||||
|
||||
|
||||
dp = malloc(sizeof(struct delif_pbuf));
|
||||
data = malloc(p->tot_len);
|
||||
|
||||
i = 0;
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
for(j = 0; j < q->len; j++) {
|
||||
data[i] = ((char *)q->payload)[j];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dp->p = pbuf_alloc(PBUF_LINK, 0, PBUF_ROM);
|
||||
dp->p->payload = data;
|
||||
dp->p->len = p->tot_len;
|
||||
dp->p->tot_len = p->tot_len;
|
||||
dp->ipaddr = ipaddr;
|
||||
dp->time = sys_now() + DELIF_OUTPUT_DELAY;
|
||||
dp->next = NULL;
|
||||
if(output_list == NULL) {
|
||||
output_list = dp;
|
||||
} else {
|
||||
for(np = output_list; np->next != NULL; np = np->next);
|
||||
np->next = dp;
|
||||
}
|
||||
|
||||
|
||||
return ERR_OK;
|
||||
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
delif_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
struct delif_pbuf *dp, *np;
|
||||
|
||||
DEBUGF(DELIF_DEBUG, ("delif_input\n"));
|
||||
#ifdef DELIF_INPUT_DROPRATE
|
||||
if(((double)rand()/(double)RAND_MAX) < DELIF_INPUT_DROPRATE) {
|
||||
DEBUGF(DELIF_DEBUG, ("delif_input: Packet dropped\n"));
|
||||
pbuf_free(p);
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* DELIF_INPUT_DROPRATE */
|
||||
|
||||
|
||||
dp = malloc(sizeof(struct delif_pbuf));
|
||||
dp->p = p;
|
||||
dp->time = sys_now() + DELIF_INPUT_DELAY;
|
||||
dp->next = NULL;
|
||||
if(input_list == NULL) {
|
||||
input_list = dp;
|
||||
} else {
|
||||
for(np = input_list; np->next != NULL; np = np->next);
|
||||
np->next = dp;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
delif_init(struct netif *netif)
|
||||
{
|
||||
struct delif *del;
|
||||
|
||||
del = malloc(sizeof(struct delif));
|
||||
netif->state = del;
|
||||
netif->name[0] = 'd';
|
||||
netif->name[1] = 'e';
|
||||
netif->output = delif_output;
|
||||
|
||||
del->netif = malloc(sizeof(struct netif));
|
||||
#ifdef linux
|
||||
/* tapif_init(del->netif);*/
|
||||
tunif_init(del->netif);
|
||||
#else /* linux */
|
||||
tunif_init(del->netif);
|
||||
#endif /* linux */
|
||||
del->input = netif->input;
|
||||
del->netif->input = delif_input;
|
||||
sys_timeout(DELIF_TIMEOUT, delif_input_timeout, netif);
|
||||
sys_timeout(DELIF_TIMEOUT, delif_output_timeout, netif);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
delif_thread(void *arg)
|
||||
{
|
||||
struct netif *netif = arg;
|
||||
struct delif *del;
|
||||
sys_sem_t sem;
|
||||
|
||||
del = netif->state;
|
||||
#ifdef linux
|
||||
tapif_init(del->netif);
|
||||
#else /* linux */
|
||||
tunif_init(del->netif);
|
||||
#endif /* linux */
|
||||
|
||||
sys_timeout(DELIF_TIMEOUT, delif_input_timeout, netif);
|
||||
sys_timeout(DELIF_TIMEOUT, delif_output_timeout, netif);
|
||||
|
||||
sem = sys_sem_new(0);
|
||||
sys_sem_wait(sem);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
delif_init_thread(struct netif *netif)
|
||||
{
|
||||
struct delif *del;
|
||||
|
||||
DEBUGF(DELIF_DEBUG, ("delif_init_thread\n"));
|
||||
|
||||
del = malloc(sizeof(struct delif));
|
||||
netif->state = del;
|
||||
netif->name[0] = 'd';
|
||||
netif->name[1] = 'e';
|
||||
netif->output = delif_output;
|
||||
|
||||
del->netif = malloc(sizeof(struct netif));
|
||||
del->netif->ip_addr = netif->ip_addr;
|
||||
del->netif->gw = netif->gw;
|
||||
del->netif->netmask = netif->netmask;
|
||||
del->input = netif->input;
|
||||
del->netif->input = delif_input;
|
||||
sys_thread_new(delif_thread, netif);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "lwip/list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct list {
|
||||
struct elem *first, *last;
|
||||
int size, elems;
|
||||
};
|
||||
|
||||
struct elem {
|
||||
struct elem *next;
|
||||
void *data;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct list *
|
||||
list_new(int size)
|
||||
{
|
||||
struct list *list;
|
||||
list = malloc(sizeof(struct list));
|
||||
list->first = list->last = NULL;
|
||||
list->size = size;
|
||||
list->elems = 0;
|
||||
return list;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
list_push(struct list *list, void *data)
|
||||
{
|
||||
struct elem *elem;
|
||||
|
||||
if(list->elems < list->size) {
|
||||
elem = malloc(sizeof(struct elem));
|
||||
elem->data = data;
|
||||
elem->next = NULL;
|
||||
if(list->last != NULL) {
|
||||
list->last->next = elem;
|
||||
}
|
||||
list->last = elem;
|
||||
if(list->first == NULL) {
|
||||
list->first = elem;
|
||||
}
|
||||
list->elems++;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void *
|
||||
list_pop(struct list *list)
|
||||
{
|
||||
struct elem *elem;
|
||||
void *data;
|
||||
|
||||
if(list->elems > 0) {
|
||||
elem = list->first;
|
||||
if(elem == list->last) {
|
||||
list->last = elem->next;
|
||||
}
|
||||
list->first = elem->next;
|
||||
|
||||
list->elems--;
|
||||
|
||||
data = elem->data;
|
||||
free(elem);
|
||||
|
||||
return data;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void *
|
||||
list_first(struct list *list)
|
||||
{
|
||||
return list->first;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
list_elems(struct list *list)
|
||||
{
|
||||
return list->elems;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
list_delete(struct list *list)
|
||||
{
|
||||
while(list_pop(list) != NULL);
|
||||
free(list);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
list_remove(struct list *list, void *elem)
|
||||
{
|
||||
struct elem *e, *p;
|
||||
|
||||
p = NULL;
|
||||
for(e = list->first; e != NULL; e = e->next) {
|
||||
if(e->data == elem) {
|
||||
if(p != NULL) {
|
||||
p->next = e->next;
|
||||
} else {
|
||||
list->first = e->next;
|
||||
}
|
||||
if(list->last == e) {
|
||||
list->last = p;
|
||||
if(p != NULL) {
|
||||
p->next = NULL;
|
||||
}
|
||||
}
|
||||
free(e);
|
||||
list->elems--;
|
||||
return 1;
|
||||
}
|
||||
p = e;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
list_map(struct list *list, void (* func)(void *arg))
|
||||
{
|
||||
struct elem *e;
|
||||
|
||||
for(e = list->first; e != NULL; e = e->next) {
|
||||
func(e->data);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef linux /* Apparently, this doesn't work under Linux. */
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "netif/unixif.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/ip.h"
|
||||
|
||||
#include "lwip/list.h"
|
||||
|
||||
#include "netif/tcpdump.h"
|
||||
|
||||
struct pcapif {
|
||||
pcap_t *pd;
|
||||
sys_sem_t sem;
|
||||
u8_t pkt[2048];
|
||||
u32_t len;
|
||||
u32_t lasttime;
|
||||
struct pbuf *p;
|
||||
struct eth_addr *ethaddr;
|
||||
};
|
||||
|
||||
static char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
pcapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
timeout(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct pcapif *pcapif;
|
||||
struct pbuf *p, *q;
|
||||
u8_t *bufptr;
|
||||
struct eth_hdr *ethhdr;
|
||||
|
||||
netif = (struct netif *)arg;
|
||||
pcapif = netif->state;
|
||||
ethhdr = (struct eth_hdr *)pcapif->pkt;
|
||||
|
||||
|
||||
if(htons(ethhdr->type) != ETHTYPE_IP ||
|
||||
ip_lookup(pcapif->pkt + 14, netif)) {
|
||||
|
||||
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||
p = pbuf_alloc(PBUF_LINK, pcapif->len, PBUF_POOL);
|
||||
|
||||
if(p != NULL) {
|
||||
/* We iterate over the pbuf chain until we have read the entire
|
||||
packet into the pbuf. */
|
||||
bufptr = (u_char *)pcapif->pkt;
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Read enough bytes to fill this pbuf in the chain. The
|
||||
avaliable data in the pbuf is given by the q->len
|
||||
variable. */
|
||||
/* read data into(q->payload, q->len); */
|
||||
bcopy(bufptr, q->payload, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
|
||||
ethhdr = p->payload;
|
||||
switch(htons(ethhdr->type)) {
|
||||
case ETHTYPE_IP:
|
||||
arp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
p = arp_arp_input(netif, pcapif->ethaddr, p);
|
||||
if(p != NULL) {
|
||||
printf("ARP outout\n");
|
||||
pbuf_free(p);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("ip_lookup dropped\n");
|
||||
}
|
||||
|
||||
sys_sem_signal(pcapif->sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
callback(u_char *arg, const struct pcap_pkthdr *hdr, const u_char *pkt)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct pcapif *pcapif;
|
||||
u32_t time, lasttime;
|
||||
|
||||
netif = (struct netif *)arg;
|
||||
pcapif = netif->state;
|
||||
|
||||
pcapif->len = hdr->len;
|
||||
|
||||
bcopy(pkt, pcapif->pkt, hdr->len);
|
||||
|
||||
time = hdr->ts.tv_sec * 1000 + hdr->ts.tv_usec / 1000;
|
||||
|
||||
lasttime = pcapif->lasttime;
|
||||
pcapif->lasttime = time;
|
||||
|
||||
|
||||
if(lasttime == 0) {
|
||||
sys_timeout(1000, timeout, netif);
|
||||
} else {
|
||||
sys_timeout(time - lasttime, timeout, netif);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
pcapif_thread(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct pcapif *pcapif;
|
||||
netif = arg;
|
||||
pcapif = netif->state;
|
||||
|
||||
while(1) {
|
||||
pcap_loop(pcapif->pd, 1, callback, (u_char *)netif);
|
||||
sys_sem_wait(pcapif->sem);
|
||||
if(pcapif->p != NULL) {
|
||||
netif->input(pcapif->p, netif);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
pcapif_init(struct netif *netif)
|
||||
{
|
||||
struct pcapif *p;
|
||||
|
||||
p = malloc(sizeof(struct pcapif));
|
||||
netif->state = p;
|
||||
netif->name[0] = 'p';
|
||||
netif->name[1] = 'c';
|
||||
netif->output = pcapif_output;
|
||||
|
||||
p->pd = pcap_open_offline("pcapdump", errbuf);
|
||||
if(p->pd == NULL) {
|
||||
printf("pcapif_init: failed %s\n", errbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
p->sem = sys_sem_new(0);
|
||||
p->p = NULL;
|
||||
p->lasttime = 0;
|
||||
|
||||
sys_thread_new(pcapif_thread, netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#endif /* linux */
|
||||
@@ -1,189 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
#include "lwip/def.h"
|
||||
#include "netif/sioslipif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
/* The maximum size that an incoming packet can have. */
|
||||
#define MAX_SIZE 1500
|
||||
|
||||
#define SLIP_END 0300
|
||||
#define SLIP_ESC 0333
|
||||
#define SLIP_ESC_END 0334
|
||||
#define SLIP_ESC_ESC 0335
|
||||
|
||||
/* Define those to whatever is needed to send and receive one byte of
|
||||
data. */
|
||||
#define SIO_SEND(c)
|
||||
#define SIO_RECV(c)
|
||||
|
||||
static const unsigned char slip_end = SLIP_END,
|
||||
slip_esc = SLIP_ESC,
|
||||
slip_esc_end = SLIP_ESC_END,
|
||||
slip_esc_esc = SLIP_ESC_ESC;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
sioslipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
||||
{
|
||||
struct pbuf *q;
|
||||
int i;
|
||||
unsigned char *ptr;
|
||||
u8_t c;
|
||||
/* Send pbuf out on the serial I/O device. */
|
||||
SIO_SEND(slip_end);
|
||||
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
ptr = q->payload;
|
||||
for(i = 0; i < q->len; i++) {
|
||||
c = *ptr++;
|
||||
switch(c) {
|
||||
case SLIP_END:
|
||||
SIO_SEND(slip_esc);
|
||||
SIO_SEND(slip_esc_end);
|
||||
break;
|
||||
case SLIP_ESC:
|
||||
SIO_SEND(slip_esc);
|
||||
SIO_SEND(slip_esc_esc);
|
||||
break;
|
||||
default:
|
||||
SIO_SEND(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef LINK_STATS
|
||||
stats.link.xmit++;
|
||||
#endif /* LINK_STATS */
|
||||
SIO_SEND(slip_end);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct pbuf *
|
||||
sioslipif_input(void)
|
||||
{
|
||||
u8_t c;
|
||||
struct pbuf *p, *q;
|
||||
int recved;
|
||||
int i;
|
||||
|
||||
q = p = NULL;
|
||||
recved = i = 0;
|
||||
c = 0;
|
||||
|
||||
while(1) {
|
||||
SIO_RECV(c);
|
||||
switch(c) {
|
||||
case SLIP_END:
|
||||
if(p == NULL) {
|
||||
return sioslipif_input();
|
||||
}
|
||||
if(recved > 0) {
|
||||
/* Received whole packet. */
|
||||
pbuf_realloc(q, recved);
|
||||
#ifdef LINK_STATS
|
||||
stats.link.recv++;
|
||||
#endif /* LINK_STATS */
|
||||
return q;
|
||||
}
|
||||
break;
|
||||
case SLIP_ESC:
|
||||
SIO_RECV(c);
|
||||
switch(c) {
|
||||
case SLIP_ESC_END:
|
||||
c = SLIP_END;
|
||||
break;
|
||||
case SLIP_ESC_ESC:
|
||||
c = SLIP_ESC;
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if(p == NULL) {
|
||||
p = pbuf_alloc(PBUF_LINK, 128, PBUF_POOL);
|
||||
#ifdef LINK_STATS
|
||||
if(p == NULL) {
|
||||
stats.link.drop++;
|
||||
}
|
||||
#endif /* LINK_STATS */
|
||||
if(q != NULL) {
|
||||
pbuf_chain(q, p);
|
||||
} else {
|
||||
q = p;
|
||||
}
|
||||
}
|
||||
if(p != NULL && recved < MAX_SIZE) {
|
||||
((u8_t *)p->payload)[i] = c;
|
||||
recved++;
|
||||
i++;
|
||||
if(i >= p->len) {
|
||||
i = 0;
|
||||
p = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
sioslipif_loop(void *arg)
|
||||
{
|
||||
struct pbuf *p;
|
||||
struct netif *netif;
|
||||
|
||||
netif = arg;
|
||||
while(1) {
|
||||
p = sioslipif_input();
|
||||
netif->input(p, netif);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sioslipif_init(struct netif *netif)
|
||||
{
|
||||
netif->state = NULL;
|
||||
netif->name[0] = 's';
|
||||
netif->name[1] = 'l';
|
||||
netif->output = sioslipif_output;
|
||||
|
||||
sys_thread_new((void *)sioslipif_loop, netif);
|
||||
/* Do some magic to make it possible to receive data from the serial I/O device. */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -1,355 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#ifdef linux
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/if_tun.h>
|
||||
#define DEVTAP "/dev/net/tun"
|
||||
#else /* linux */
|
||||
#define DEVTAP "/dev/tap0"
|
||||
#endif /* linux */
|
||||
|
||||
#define IFNAME0 't'
|
||||
#define IFNAME1 'p'
|
||||
|
||||
static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
|
||||
|
||||
struct tapif {
|
||||
struct eth_addr *ethaddr;
|
||||
/* Add whatever per-interface state that is needed here. */
|
||||
int fd;
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
static void tapif_input(struct netif *netif);
|
||||
static err_t tapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr);
|
||||
|
||||
static void tapif_thread(void *data);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
struct tapif *tapif;
|
||||
char buf[100];
|
||||
|
||||
tapif = netif->state;
|
||||
|
||||
/* Obtain MAC address from network interface. */
|
||||
|
||||
/* (We just fake an address...) */
|
||||
tapif->ethaddr->addr[0] = 0x1;
|
||||
tapif->ethaddr->addr[1] = 0x2;
|
||||
tapif->ethaddr->addr[2] = 0x3;
|
||||
tapif->ethaddr->addr[3] = 0x4;
|
||||
tapif->ethaddr->addr[4] = 0x5;
|
||||
tapif->ethaddr->addr[5] = 0x6;
|
||||
|
||||
/* Do whatever else is needed to initialize interface. */
|
||||
|
||||
tapif->fd = open(DEVTAP, O_RDWR);
|
||||
DEBUGF(TAPIF_DEBUG, ("tapif_init: fd %d\n", tapif->fd));
|
||||
if(tapif->fd == -1) {
|
||||
perror("tapif_init");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef linux
|
||||
{
|
||||
struct ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
|
||||
if (ioctl(tapif->fd, TUNSETIFF, (void *) &ifr) < 0) {
|
||||
perror(buf);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#endif /* Linux */
|
||||
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet %d.%d.%d.%d",
|
||||
ip4_addr1(&(netif->gw)),
|
||||
ip4_addr2(&(netif->gw)),
|
||||
ip4_addr3(&(netif->gw)),
|
||||
ip4_addr4(&(netif->gw)));
|
||||
|
||||
DEBUGF(TAPIF_DEBUG, ("tapif_init: system(\"%s\");\n", buf));
|
||||
system(buf);
|
||||
sys_thread_new(tapif_thread, netif);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* low_level_output():
|
||||
*
|
||||
* Should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
* might be chained.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
low_level_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct pbuf *q;
|
||||
char buf[1500];
|
||||
char *bufptr;
|
||||
struct tapif *tapif;
|
||||
|
||||
tapif = netif->state;
|
||||
|
||||
/* initiate transfer(); */
|
||||
|
||||
bufptr = &buf[0];
|
||||
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Send the data from the pbuf to the interface, one pbuf at a
|
||||
time. The size of the data in each pbuf is kept in the ->len
|
||||
variable. */
|
||||
/* send data from(q->payload, q->len); */
|
||||
bcopy(q->payload, bufptr, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
|
||||
/* signal that packet should be sent(); */
|
||||
if(write(tapif->fd, buf, p->tot_len) == -1) {
|
||||
perror("tapif: write");
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* low_level_input():
|
||||
*
|
||||
* Should allocate a pbuf and transfer the bytes of the incoming
|
||||
* packet from the interface into the pbuf.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct pbuf *
|
||||
low_level_input(struct tapif *tapif)
|
||||
{
|
||||
struct pbuf *p, *q;
|
||||
u16_t len;
|
||||
char buf[1500];
|
||||
char *bufptr;
|
||||
|
||||
/* Obtain the size of the packet and put it into the "len"
|
||||
variable. */
|
||||
len = read(tapif->fd, buf, sizeof(buf));
|
||||
|
||||
/* if(((double)rand()/(double)RAND_MAX) < 0.1) {
|
||||
printf("drop\n");
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
|
||||
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
|
||||
|
||||
if(p != NULL) {
|
||||
/* We iterate over the pbuf chain until we have read the entire
|
||||
packet into the pbuf. */
|
||||
bufptr = &buf[0];
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Read enough bytes to fill this pbuf in the chain. The
|
||||
avaliable data in the pbuf is given by the q->len
|
||||
variable. */
|
||||
/* read data into(q->payload, q->len); */
|
||||
bcopy(bufptr, q->payload, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
/* acknowledge that packet has been read(); */
|
||||
} else {
|
||||
/* drop packet(); */
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tapif_thread(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct tapif *tapif;
|
||||
fd_set fdset;
|
||||
int ret;
|
||||
|
||||
netif = arg;
|
||||
tapif = netif->state;
|
||||
|
||||
while(1) {
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(tapif->fd, &fdset);
|
||||
|
||||
/* Wait for a packet to arrive. */
|
||||
ret = select(tapif->fd + 1, &fdset, NULL, NULL, NULL);
|
||||
|
||||
if(ret == 1) {
|
||||
/* Handle incoming packet. */
|
||||
tapif_input(netif);
|
||||
} else if(ret == -1) {
|
||||
perror("tapif_thread: select");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* tapif_output():
|
||||
*
|
||||
* This function is called by the TCP/IP stack when an IP packet
|
||||
* should be sent. It calls the function called low_level_output() to
|
||||
* do the actuall transmission of the packet.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
tapif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
p = etharp_output(netif, ipaddr, p);
|
||||
if(p != NULL) {
|
||||
return low_level_output(netif, p);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* tapif_input():
|
||||
*
|
||||
* This function should be called when a packet is ready to be read
|
||||
* from the interface. It uses the function low_level_input() that
|
||||
* should handle the actual reception of bytes from the network
|
||||
* interface.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tapif_input(struct netif *netif)
|
||||
{
|
||||
struct tapif *tapif;
|
||||
struct eth_hdr *ethhdr;
|
||||
struct pbuf *p, *q;
|
||||
|
||||
|
||||
tapif = netif->state;
|
||||
|
||||
p = low_level_input(tapif);
|
||||
|
||||
if(p == NULL) {
|
||||
DEBUGF(TAPIF_DEBUG, ("tapif_input: low_level_input returned NULL\n"));
|
||||
return;
|
||||
}
|
||||
ethhdr = p->payload;
|
||||
|
||||
q = NULL;
|
||||
switch(htons(ethhdr->type)) {
|
||||
case ETHTYPE_IP:
|
||||
DEBUGF(TAPIF_DEBUG, ("tapif_input: IP packet\n"));
|
||||
q = etharp_ip_input(netif, p);
|
||||
pbuf_header(p, -14);
|
||||
netif->input(p, netif);
|
||||
break;
|
||||
case ETHTYPE_ARP:
|
||||
DEBUGF(TAPIF_DEBUG, ("tapif_input: ARP packet\n"));
|
||||
q = etharp_arp_input(netif, tapif->ethaddr, p);
|
||||
break;
|
||||
default:
|
||||
pbuf_free(p);
|
||||
break;
|
||||
}
|
||||
if(q != NULL) {
|
||||
low_level_output(netif, q);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
arp_timer(void *arg)
|
||||
{
|
||||
etharp_tmr();
|
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* tapif_init():
|
||||
*
|
||||
* Should be called at the beginning of the program to set up the
|
||||
* network interface. It calls the function low_level_init() to do the
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
tapif_init(struct netif *netif)
|
||||
{
|
||||
struct tapif *tapif;
|
||||
|
||||
tapif = mem_malloc(sizeof(struct tapif));
|
||||
netif->state = tapif;
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
netif->output = tapif_output;
|
||||
netif->linkoutput = low_level_output;
|
||||
|
||||
tapif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
||||
|
||||
low_level_init(netif);
|
||||
etharp_init();
|
||||
|
||||
sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -1,298 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
|
||||
#define IFNAME0 't'
|
||||
#define IFNAME1 'n'
|
||||
|
||||
struct tunif {
|
||||
/* Add whatever per-interface state that is needed here. */
|
||||
int fd;
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
static void tunif_input(struct netif *netif);
|
||||
static err_t tunif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr);
|
||||
|
||||
static void tunif_thread(void *data);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
struct tunif *tunif;
|
||||
char buf[100];
|
||||
|
||||
tunif = netif->state;
|
||||
|
||||
/* Obtain MAC address from network interface. */
|
||||
|
||||
/* Do whatever else is needed to initialize interface. */
|
||||
|
||||
tunif->fd = open("/dev/tun0", O_RDWR);
|
||||
DEBUGF(TUNIF_DEBUG, ("tunif_init: fd %d\n", tunif->fd));
|
||||
if(tunif->fd == -1) {
|
||||
perror("tunif_init");
|
||||
exit(1);
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "ifconfig tun0 inet %d.%d.%d.%d %d.%d.%d.%d",
|
||||
ip4_addr1(&(netif->gw)),
|
||||
ip4_addr2(&(netif->gw)),
|
||||
ip4_addr3(&(netif->gw)),
|
||||
ip4_addr4(&(netif->gw)),
|
||||
ip4_addr1(&(netif->ip_addr)),
|
||||
ip4_addr2(&(netif->ip_addr)),
|
||||
ip4_addr3(&(netif->ip_addr)),
|
||||
ip4_addr4(&(netif->ip_addr)));
|
||||
|
||||
DEBUGF(TUNIF_DEBUG, ("tunif_init: system(\"%s\");\n", buf));
|
||||
system(buf);
|
||||
sys_thread_new(tunif_thread, netif);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* low_level_output():
|
||||
*
|
||||
* Should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
* might be chained.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
low_level_output(struct tunif *tunif, struct pbuf *p)
|
||||
{
|
||||
struct pbuf *q;
|
||||
char buf[1500];
|
||||
char *bufptr;
|
||||
|
||||
/* initiate transfer(); */
|
||||
|
||||
if(((double)rand()/(double)RAND_MAX) < 0.4) {
|
||||
printf("drop\n");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
bufptr = &buf[0];
|
||||
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Send the data from the pbuf to the interface, one pbuf at a
|
||||
time. The size of the data in each pbuf is kept in the ->len
|
||||
variable. */
|
||||
/* send data from(q->payload, q->len); */
|
||||
bcopy(q->payload, bufptr, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
|
||||
/* signal that packet should be sent(); */
|
||||
if(write(tunif->fd, buf, p->tot_len) == -1) {
|
||||
perror("tunif: write");
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* low_level_input():
|
||||
*
|
||||
* Should allocate a pbuf and transfer the bytes of the incoming
|
||||
* packet from the interface into the pbuf.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct pbuf *
|
||||
low_level_input(struct tunif *tunif)
|
||||
{
|
||||
struct pbuf *p, *q;
|
||||
u16_t len;
|
||||
char buf[1500];
|
||||
char *bufptr;
|
||||
|
||||
/* Obtain the size of the packet and put it into the "len"
|
||||
variable. */
|
||||
len = read(tunif->fd, buf, sizeof(buf));
|
||||
|
||||
/* if(((double)rand()/(double)RAND_MAX) < 0.1) {
|
||||
printf("drop\n");
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
|
||||
/* We allocate a pbuf chain of pbufs from the pool. */
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
|
||||
|
||||
if(p != NULL) {
|
||||
/* We iterate over the pbuf chain until we have read the entire
|
||||
packet into the pbuf. */
|
||||
bufptr = &buf[0];
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
/* Read enough bytes to fill this pbuf in the chain. The
|
||||
avaliable data in the pbuf is given by the q->len
|
||||
variable. */
|
||||
/* read data into(q->payload, q->len); */
|
||||
bcopy(bufptr, q->payload, q->len);
|
||||
bufptr += q->len;
|
||||
}
|
||||
/* acknowledge that packet has been read(); */
|
||||
} else {
|
||||
/* drop packet(); */
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tunif_thread(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct tunif *tunif;
|
||||
fd_set fdset;
|
||||
int ret;
|
||||
|
||||
netif = arg;
|
||||
tunif = netif->state;
|
||||
|
||||
while(1) {
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(tunif->fd, &fdset);
|
||||
|
||||
/* Wait for a packet to arrive. */
|
||||
ret = select(tunif->fd + 1, &fdset, NULL, NULL, NULL);
|
||||
|
||||
if(ret == 1) {
|
||||
/* Handle incoming packet. */
|
||||
tunif_input(netif);
|
||||
} else if(ret == -1) {
|
||||
perror("tunif_thread: select");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* tunif_output():
|
||||
*
|
||||
* This function is called by the TCP/IP stack when an IP packet
|
||||
* should be sent. It calls the function called low_level_output() to
|
||||
* do the actuall transmission of the packet.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static err_t
|
||||
tunif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
struct tunif *tunif;
|
||||
|
||||
tunif = netif->state;
|
||||
|
||||
return low_level_output(tunif, p);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* tunif_input():
|
||||
*
|
||||
* This function should be called when a packet is ready to be read
|
||||
* from the interface. It uses the function low_level_input() that
|
||||
* should handle the actual reception of bytes from the network
|
||||
* interface.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
tunif_input(struct netif *netif)
|
||||
{
|
||||
struct tunif *tunif;
|
||||
struct pbuf *p;
|
||||
|
||||
|
||||
tunif = netif->state;
|
||||
|
||||
p = low_level_input(tunif);
|
||||
|
||||
if(p == NULL) {
|
||||
DEBUGF(TUNIF_DEBUG, ("tunif_input: low_level_input returned NULL\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(ip_lookup(p->payload, netif)) {
|
||||
netif->input(p, netif);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* tunif_init():
|
||||
*
|
||||
* Should be called at the beginning of the program to set up the
|
||||
* network interface. It calls the function low_level_init() to do the
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
tunif_init(struct netif *netif)
|
||||
{
|
||||
struct tunif *tunif;
|
||||
|
||||
tunif = mem_malloc(sizeof(struct tunif));
|
||||
netif->state = tunif;
|
||||
netif->name[0] = IFNAME0;
|
||||
netif->name[1] = IFNAME1;
|
||||
netif->output = tunif_output;
|
||||
|
||||
|
||||
low_level_init(netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -1,480 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "netif/unixif.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "lwip/list.h"
|
||||
|
||||
#include "netif/tcpdump.h"
|
||||
|
||||
#define UNIXIF_BPS 512000
|
||||
#define UNIXIF_QUEUELEN 6
|
||||
/*#define UNIXIF_DROP_FIRST */
|
||||
|
||||
struct unixif_buf {
|
||||
struct pbuf *p;
|
||||
unsigned short len, tot_len;
|
||||
void *payload;
|
||||
};
|
||||
|
||||
struct unixif {
|
||||
int fd;
|
||||
sys_sem_t sem;
|
||||
struct list *q;
|
||||
};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static int
|
||||
unix_socket_client(char *name)
|
||||
{
|
||||
int fd, len;
|
||||
struct sockaddr_un unix_addr;
|
||||
|
||||
/* create a Unix domain stream socket */
|
||||
if((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
perror("unixif: unix_socket_client: socket");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* fill socket address structure w/our address */
|
||||
memset(&unix_addr, 0, sizeof(unix_addr));
|
||||
unix_addr.sun_family = AF_UNIX;
|
||||
sprintf(unix_addr.sun_path, "%s%05d", "/var/tmp/", getpid());
|
||||
#ifndef linux
|
||||
len = sizeof(unix_addr.sun_len) + sizeof(unix_addr.sun_family) +
|
||||
strlen(unix_addr.sun_path) + 1;
|
||||
unix_addr.sun_len = len;
|
||||
#else
|
||||
len = sizeof(unix_addr.sun_family) +
|
||||
strlen(unix_addr.sun_path) + 1;
|
||||
#endif /* linux */
|
||||
|
||||
unlink(unix_addr.sun_path); /* in case it already exists */
|
||||
if(bind(fd, (struct sockaddr *) &unix_addr,
|
||||
sizeof(struct sockaddr_un)) < 0) {
|
||||
perror("unixif: unix_socket_client: socket");
|
||||
return(-1);
|
||||
}
|
||||
if(chmod(unix_addr.sun_path, S_IRWXU | S_IRWXO) < 0) {
|
||||
perror("unixif: unix_socket_client: socket");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* fill socket address structure w/server's addr */
|
||||
memset(&unix_addr, 0, sizeof(unix_addr));
|
||||
unix_addr.sun_family = AF_UNIX;
|
||||
strcpy(unix_addr.sun_path, name);
|
||||
#ifndef linux
|
||||
len = sizeof(unix_addr.sun_len) + sizeof(unix_addr.sun_family) +
|
||||
strlen(unix_addr.sun_path) + 1;
|
||||
unix_addr.sun_len = len;
|
||||
#else
|
||||
len = sizeof(unix_addr.sun_family) + strlen(unix_addr.sun_path) + 1;
|
||||
#endif /* linux */
|
||||
if(connect(fd, (struct sockaddr *) &unix_addr,
|
||||
sizeof(struct sockaddr_un)) < 0) {
|
||||
perror("unixif: unix_socket_client: socket");
|
||||
return(-1);
|
||||
}
|
||||
return(fd);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static int
|
||||
unix_socket_server(char *name)
|
||||
{
|
||||
int fd, len;
|
||||
struct sockaddr_un unix_addr;
|
||||
|
||||
/* create a Unix domain stream socket */
|
||||
if((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||
perror("unixif: unix_socket_server: socket");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
unlink(name); /* in case it already exists */
|
||||
|
||||
/* fill in socket address structure */
|
||||
memset(&unix_addr, 0, sizeof(unix_addr));
|
||||
unix_addr.sun_family = AF_UNIX;
|
||||
strcpy(unix_addr.sun_path, name);
|
||||
#ifndef linux
|
||||
len = sizeof(unix_addr.sun_len) + sizeof(unix_addr.sun_family) +
|
||||
strlen(unix_addr.sun_path) + 1;
|
||||
unix_addr.sun_len = len;
|
||||
#else
|
||||
len = sizeof(unix_addr.sun_family) +
|
||||
strlen(unix_addr.sun_path) + 1;
|
||||
#endif /* linux */
|
||||
|
||||
/* bind the name to the descriptor */
|
||||
if(bind(fd, (struct sockaddr *) &unix_addr,
|
||||
sizeof(struct sockaddr_un)) < 0) {
|
||||
perror("unixif: unix_socket_server: bind");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
if(chmod(unix_addr.sun_path, S_IRWXU | S_IRWXO) < 0) {
|
||||
perror("unixif: unix_socket_server: chmod");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
if(listen(fd, 5) < 0) { /* tell kernel we're a server */
|
||||
perror("unixif: unix_socket_server: listen");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return(fd);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
unixif_input_handler(void *data)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct unixif *unixif;
|
||||
char buf[4096], *bufptr;
|
||||
int len, plen, rlen;
|
||||
struct pbuf *p, *q;
|
||||
|
||||
netif = data;
|
||||
unixif = netif->state;
|
||||
|
||||
len = read(unixif->fd, &plen, sizeof(int));
|
||||
if(len == -1) {
|
||||
perror("unixif_irq_handler: read");
|
||||
abort();
|
||||
}
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_irq_handler: len == %d plen == %d bytes\n", len, plen));
|
||||
if(len == sizeof(int)) {
|
||||
|
||||
if(plen < 20 || plen > 1500) {
|
||||
DEBUGF(UNIXIF_DEBUG, ("plen %d!\n", plen));
|
||||
return;
|
||||
}
|
||||
|
||||
len = read(unixif->fd, buf, plen);
|
||||
if(len == -1) {
|
||||
perror("unixif_irq_handler: read");
|
||||
abort();
|
||||
}
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_irq_handler: read %d bytes\n", len));
|
||||
p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL);
|
||||
|
||||
if(p != NULL) {
|
||||
rlen = len;
|
||||
bufptr = buf;
|
||||
q = p;
|
||||
while(rlen > 0) {
|
||||
bcopy(bufptr, q->payload, rlen > q->len? q->len: rlen);
|
||||
rlen -= q->len;
|
||||
bufptr += q->len;
|
||||
q = q->next;
|
||||
}
|
||||
pbuf_realloc(p, len);
|
||||
#ifdef LINK_STATS
|
||||
stats.link.recv++;
|
||||
#endif /* LINK_STATS */
|
||||
tcpdump(p);
|
||||
netif->input(p, netif);
|
||||
} else {
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_irq_handler: could not allocate pbuf\n"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
unixif_thread(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct unixif *unixif;
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_thread: started.\n"));
|
||||
|
||||
netif = arg;
|
||||
unixif = netif->state;
|
||||
|
||||
|
||||
while(1) {
|
||||
sys_sem_wait(unixif->sem);
|
||||
unixif_input_handler(netif);
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
unixif_thread2(void *arg)
|
||||
{
|
||||
struct netif *netif;
|
||||
struct unixif *unixif;
|
||||
fd_set fdset;
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_thread2: started.\n"));
|
||||
|
||||
netif = arg;
|
||||
unixif = netif->state;
|
||||
|
||||
while(1) {
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(unixif->fd, &fdset);
|
||||
|
||||
if(select(unixif->fd + 1, &fdset, NULL, NULL, NULL) > 0) {
|
||||
sys_sem_signal(unixif->sem);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void unixif_output_timeout(void *arg);
|
||||
|
||||
static err_t
|
||||
unixif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
||||
{
|
||||
struct unixif *unixif;
|
||||
struct unixif_buf *buf;
|
||||
unixif = netif->state;
|
||||
|
||||
buf = malloc(sizeof(struct unixif_buf));
|
||||
buf->p = p;
|
||||
buf->len = p->len;
|
||||
buf->tot_len = p->tot_len;
|
||||
buf->payload = p->payload;
|
||||
|
||||
if(list_elems(unixif->q) == 0) {
|
||||
pbuf_ref(p);
|
||||
list_push(unixif->q, buf);
|
||||
sys_timeout((double)p->tot_len * 8000.0 / UNIXIF_BPS, unixif_output_timeout,
|
||||
netif);
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_output: first on list\n"));
|
||||
|
||||
} else {
|
||||
pbuf_ref(p);
|
||||
if(list_push(unixif->q, buf) == 0) {
|
||||
#ifdef UNIXIF_DROP_FIRST
|
||||
struct unixif_buf *buf2;
|
||||
|
||||
buf2 = list_pop(unixif->q);
|
||||
pbuf_free(buf2->p);
|
||||
free(buf2);
|
||||
list_push(unixif->q, buf);
|
||||
#else
|
||||
free(buf);
|
||||
pbuf_free(p);
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_output: drop\n"));
|
||||
|
||||
#endif /* UNIXIF_DROP_FIRST */
|
||||
#ifdef LINK_STATS
|
||||
stats.link.drop++;
|
||||
#endif /* LINK_STATS */
|
||||
|
||||
} else {
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_output: on list\n"));
|
||||
}
|
||||
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
unixif_output_timeout(void *arg)
|
||||
{
|
||||
struct pbuf *p, *q;
|
||||
int i, j, len;
|
||||
unsigned short plen, ptot_len;
|
||||
struct unixif_buf *buf;
|
||||
void *payload;
|
||||
struct netif *netif;
|
||||
struct unixif *unixif;
|
||||
char *data;
|
||||
|
||||
netif = arg;
|
||||
unixif = netif->state;
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_output_timeout\n"));
|
||||
|
||||
/* buf = unixif->q[0];
|
||||
unixif->q[0] = unixif->q[1];
|
||||
unixif->q[1] = NULL;*/
|
||||
buf = list_pop(unixif->q);
|
||||
|
||||
p = buf->p;
|
||||
|
||||
plen = p->len;
|
||||
ptot_len = p->tot_len;
|
||||
payload = p->payload;
|
||||
|
||||
p->len = buf->len;
|
||||
p->tot_len = buf->tot_len;
|
||||
p->payload = buf->payload;
|
||||
|
||||
|
||||
if(p->tot_len == 0) {
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("p->len!\n"));
|
||||
abort();
|
||||
}
|
||||
data = malloc(p->tot_len);
|
||||
|
||||
i = 0;
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
for(j = 0; j < q->len; j++) {
|
||||
data[i] = ((char *)q->payload)[j];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_output: sending %d (%d) bytes\n",
|
||||
p->len, p->tot_len));
|
||||
|
||||
len = p->tot_len;
|
||||
if(write(unixif->fd, &len, sizeof(int)) == -1) {
|
||||
perror("unixif_output: write");
|
||||
abort();
|
||||
}
|
||||
|
||||
if(write(unixif->fd, data, p->tot_len) == -1) {
|
||||
perror("unixif_output: write");
|
||||
abort();
|
||||
}
|
||||
tcpdump(p);
|
||||
#ifdef LINK_STATS
|
||||
stats.link.xmit++;
|
||||
#endif /* LINK_STATS */
|
||||
|
||||
free(data);
|
||||
free(buf);
|
||||
p->len = plen;
|
||||
p->tot_len = ptot_len;
|
||||
p->payload = payload;
|
||||
|
||||
pbuf_free(p);
|
||||
|
||||
/* if(unixif->q[0] != NULL) {
|
||||
sys_timeout(unixif->q[0]->tot_len * 8000 / UNIXIF_BPS,
|
||||
unixif_output_timeout, netif);
|
||||
}*/
|
||||
if(list_elems(unixif->q) > 0) {
|
||||
sys_timeout(((struct unixif_buf *)list_first(unixif->q))->tot_len *
|
||||
8000.0 / UNIXIF_BPS,
|
||||
unixif_output_timeout, netif);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
unixif_init_server(struct netif *netif)
|
||||
{
|
||||
int fd, fd2;
|
||||
struct sockaddr_un addr;
|
||||
socklen_t len;
|
||||
struct unixif *unixif;
|
||||
|
||||
fd = unix_socket_server("/tmp/unixif");
|
||||
|
||||
if(fd == -1) {
|
||||
perror("unixif_server");
|
||||
abort();
|
||||
}
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_server: fd %d\n", fd));
|
||||
|
||||
unixif = malloc(sizeof(struct unixif));
|
||||
netif->state = unixif;
|
||||
netif->name[0] = 'u';
|
||||
netif->name[1] = 'n';
|
||||
netif->output = unixif_output;
|
||||
unixif->q = list_new(UNIXIF_QUEUELEN);
|
||||
|
||||
printf("Now run ./simnode.\n");
|
||||
len = sizeof(addr);
|
||||
fd2 = accept(fd, (struct sockaddr *)&addr, &len);
|
||||
|
||||
if(fd2 == -1) {
|
||||
perror("unixif_accept");
|
||||
abort();
|
||||
}
|
||||
|
||||
DEBUGF(UNIXIF_DEBUG, ("unixif_accept: %d\n", fd2));
|
||||
|
||||
unixif->fd = fd2;
|
||||
unixif->sem = sys_sem_new(0);
|
||||
sys_thread_new(unixif_thread, netif);
|
||||
sys_thread_new(unixif_thread2, netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
unixif_init_client(struct netif *netif)
|
||||
{
|
||||
struct unixif *unixif;
|
||||
unixif = malloc(sizeof(struct unixif));
|
||||
netif->state = unixif;
|
||||
netif->name[0] = 'u';
|
||||
netif->name[1] = 'n';
|
||||
netif->output = unixif_output;
|
||||
|
||||
unixif->fd = unix_socket_client("/tmp/unixif");
|
||||
if(unixif->fd == -1) {
|
||||
perror("unixif_init");
|
||||
abort();
|
||||
}
|
||||
unixif->q = list_new(UNIXIF_QUEUELEN);
|
||||
unixif->sem = sys_sem_new(0);
|
||||
sys_thread_new(unixif_thread, netif);
|
||||
sys_thread_new(unixif_thread2, netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "arch/perf.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static FILE *f;
|
||||
|
||||
void
|
||||
perf_print(unsigned long c1l, unsigned long c1h,
|
||||
unsigned long c2l, unsigned long c2h,
|
||||
char *key)
|
||||
{
|
||||
unsigned long long start, end;
|
||||
|
||||
start = (unsigned long long)c2h << 32 | c2l;
|
||||
end = (unsigned long long)c1h << 32 | c1l;
|
||||
fprintf(f, "%s: %llu\n", key, start - end);
|
||||
fflush(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
perf_print_times(struct tms *start, struct tms *end, char *key)
|
||||
{
|
||||
fprintf(f, "%s: %lu\n", key, end->tms_stime - start->tms_stime);
|
||||
fflush(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
perf_init(char *fname)
|
||||
{
|
||||
f = fopen(fname, "w");
|
||||
}
|
||||
|
||||
@@ -1,453 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Wed Apr 17 16:05:29 EDT 2002 (James Roth)
|
||||
*
|
||||
* - Fixed an unlikely sys_thread_new() race condition.
|
||||
*
|
||||
* - Made current_thread() work with threads which where
|
||||
* not created with sys_thread_new(). This includes
|
||||
* the main thread and threads made with pthread_create().
|
||||
*
|
||||
* - Catch overflows where more than SYS_MBOX_SIZE messages
|
||||
* are waiting to be read. The sys_mbox_post() routine
|
||||
* will block until there is more room instead of just
|
||||
* leaking messages.
|
||||
*/
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#define UMAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
static struct sys_thread *threads = NULL;
|
||||
static pthread_mutex_t threads_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
struct sys_mbox_msg {
|
||||
struct sys_mbox_msg *next;
|
||||
void *msg;
|
||||
};
|
||||
|
||||
#define SYS_MBOX_SIZE 128
|
||||
|
||||
struct sys_mbox {
|
||||
int first, last;
|
||||
void *msgs[SYS_MBOX_SIZE];
|
||||
struct sys_sem *mail;
|
||||
struct sys_sem *mutex;
|
||||
int wait_send;
|
||||
};
|
||||
|
||||
struct sys_sem {
|
||||
unsigned int c;
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
struct sys_thread {
|
||||
struct sys_thread *next;
|
||||
struct sys_timeouts timeouts;
|
||||
pthread_t pthread;
|
||||
};
|
||||
|
||||
|
||||
static struct timeval starttime;
|
||||
|
||||
static struct sys_sem *sys_sem_new_(u8_t count);
|
||||
static void sys_sem_free_(struct sys_sem *sem);
|
||||
|
||||
static u16_t cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex,
|
||||
u16_t timeout);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct sys_thread *
|
||||
introduce_thread(pthread_t id)
|
||||
{
|
||||
struct sys_thread *thread;
|
||||
|
||||
thread = malloc(sizeof(struct sys_thread));
|
||||
|
||||
if(thread) {
|
||||
pthread_mutex_lock(&threads_mutex);
|
||||
thread->next = threads;
|
||||
thread->timeouts.next = NULL;
|
||||
thread->pthread = id;
|
||||
threads = thread;
|
||||
pthread_mutex_unlock(&threads_mutex);
|
||||
}
|
||||
|
||||
return thread;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct sys_thread *
|
||||
current_thread(void)
|
||||
{
|
||||
struct sys_thread *st;
|
||||
pthread_t pt;
|
||||
pt = pthread_self();
|
||||
pthread_mutex_lock(&threads_mutex);
|
||||
|
||||
for(st = threads; st != NULL; st = st->next) {
|
||||
if(pthread_equal(st->pthread, pt)) {
|
||||
pthread_mutex_unlock(&threads_mutex);
|
||||
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&threads_mutex);
|
||||
|
||||
st = introduce_thread(pt);
|
||||
|
||||
if(!st) {
|
||||
printf("current_thread???\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
return st;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_thread_new(void (*function)(void *arg), void *arg)
|
||||
{
|
||||
int code;
|
||||
pthread_t tmp;
|
||||
struct sys_thread *st = NULL;
|
||||
|
||||
code = pthread_create(&tmp,
|
||||
NULL,
|
||||
(void *(*)(void *))
|
||||
function,
|
||||
arg);
|
||||
|
||||
if(0 == code) {
|
||||
st = introduce_thread(tmp);
|
||||
}
|
||||
|
||||
if(NULL == st) {
|
||||
DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%x",
|
||||
code, (int)st));
|
||||
abort();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct sys_mbox *
|
||||
sys_mbox_new()
|
||||
{
|
||||
struct sys_mbox *mbox;
|
||||
|
||||
mbox = malloc(sizeof(struct sys_mbox));
|
||||
mbox->first = mbox->last = 0;
|
||||
mbox->mail = sys_sem_new_(0);
|
||||
mbox->mutex = sys_sem_new_(1);
|
||||
mbox->wait_send = 0;
|
||||
|
||||
#ifdef SYS_STATS
|
||||
stats.sys.mbox.used++;
|
||||
if(stats.sys.mbox.used > stats.sys.mbox.max) {
|
||||
stats.sys.mbox.max = stats.sys.mbox.used;
|
||||
}
|
||||
#endif /* SYS_STATS */
|
||||
|
||||
return mbox;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_mbox_free(struct sys_mbox *mbox)
|
||||
{
|
||||
if(mbox != SYS_MBOX_NULL) {
|
||||
#ifdef SYS_STATS
|
||||
stats.sys.mbox.used--;
|
||||
#endif /* SYS_STATS */
|
||||
sys_sem_wait(mbox->mutex);
|
||||
|
||||
sys_sem_free_(mbox->mail);
|
||||
sys_sem_free_(mbox->mutex);
|
||||
mbox->mail = mbox->mutex = NULL;
|
||||
/* DEBUGF("sys_mbox_free: mbox 0x%lx\n", mbox); */
|
||||
free(mbox);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_mbox_post(struct sys_mbox *mbox, void *msg)
|
||||
{
|
||||
u8_t first;
|
||||
|
||||
sys_sem_wait(mbox->mutex);
|
||||
|
||||
DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", mbox, msg));
|
||||
|
||||
while((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE)) {
|
||||
mbox->wait_send++;
|
||||
sys_sem_signal(mbox->mutex);
|
||||
sys_arch_sem_wait(mbox->mail, 0);
|
||||
sys_arch_sem_wait(mbox->mutex, 0);
|
||||
mbox->wait_send--;
|
||||
}
|
||||
|
||||
mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg;
|
||||
|
||||
if(mbox->last == mbox->first) {
|
||||
first = 1;
|
||||
} else {
|
||||
first = 0;
|
||||
}
|
||||
|
||||
mbox->last++;
|
||||
|
||||
if(first) {
|
||||
sys_sem_signal(mbox->mail);
|
||||
}
|
||||
|
||||
sys_sem_signal(mbox->mutex);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
sys_arch_mbox_fetch(struct sys_mbox *mbox, void **msg, u16_t timeout)
|
||||
{
|
||||
u16_t time = 1;
|
||||
|
||||
/* The mutex lock is quick so we don't bother with the timeout
|
||||
stuff here. */
|
||||
sys_arch_sem_wait(mbox->mutex, 0);
|
||||
|
||||
while(mbox->first == mbox->last) {
|
||||
sys_sem_signal(mbox->mutex);
|
||||
|
||||
/* We block while waiting for a mail to arrive in the mailbox. We
|
||||
must be prepared to timeout. */
|
||||
if(timeout != 0) {
|
||||
time = sys_arch_sem_wait(mbox->mail, timeout);
|
||||
|
||||
/* If time == 0, the sem_wait timed out, and we return 0. */
|
||||
if(time == 0) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
sys_arch_sem_wait(mbox->mail, 0);
|
||||
}
|
||||
|
||||
sys_arch_sem_wait(mbox->mutex, 0);
|
||||
}
|
||||
|
||||
DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", mbox, *msg));
|
||||
|
||||
if(msg != NULL) {
|
||||
*msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE];
|
||||
}
|
||||
|
||||
mbox->first++;
|
||||
|
||||
if(mbox->wait_send) {
|
||||
sys_sem_signal(mbox->mail);
|
||||
}
|
||||
|
||||
sys_sem_signal(mbox->mutex);
|
||||
|
||||
return time;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct sys_sem *
|
||||
sys_sem_new(u8_t count)
|
||||
{
|
||||
#ifdef SYS_STATS
|
||||
stats.sys.sem.used++;
|
||||
if(stats.sys.sem.used > stats.sys.sem.max) {
|
||||
stats.sys.sem.max = stats.sys.sem.used;
|
||||
}
|
||||
#endif /* SYS_STATS */
|
||||
return sys_sem_new_(count);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct sys_sem *
|
||||
sys_sem_new_(u8_t count)
|
||||
{
|
||||
struct sys_sem *sem;
|
||||
|
||||
sem = malloc(sizeof(struct sys_sem));
|
||||
sem->c = count;
|
||||
|
||||
pthread_cond_init(&(sem->cond), NULL);
|
||||
pthread_mutex_init(&(sem->mutex), NULL);
|
||||
|
||||
return sem;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static u16_t
|
||||
cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, u16_t timeout)
|
||||
{
|
||||
int tdiff;
|
||||
unsigned long sec, usec;
|
||||
struct timeval rtime1, rtime2;
|
||||
struct timespec ts;
|
||||
struct timezone tz;
|
||||
int retval;
|
||||
|
||||
if(timeout > 0) {
|
||||
/* Get a timestamp and add the timeout value. */
|
||||
gettimeofday(&rtime1, &tz);
|
||||
sec = rtime1.tv_sec;
|
||||
usec = rtime1.tv_usec;
|
||||
usec += timeout % 1000 * 1000;
|
||||
sec += (int)(timeout / 1000) + (int)(usec / 1000000);
|
||||
usec = usec % 1000000;
|
||||
ts.tv_nsec = usec * 1000;
|
||||
ts.tv_sec = sec;
|
||||
|
||||
retval = pthread_cond_timedwait(cond, mutex, &ts);
|
||||
|
||||
if(retval == ETIMEDOUT) {
|
||||
return 0;
|
||||
} else {
|
||||
/* Calculate for how long we waited for the cond. */
|
||||
gettimeofday(&rtime2, &tz);
|
||||
tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 +
|
||||
(rtime2.tv_usec - rtime1.tv_usec) / 1000;
|
||||
|
||||
if(tdiff <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return tdiff;
|
||||
}
|
||||
} else {
|
||||
pthread_cond_wait(cond, mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
sys_arch_sem_wait(struct sys_sem *sem, u16_t timeout)
|
||||
{
|
||||
u16_t time = 1;
|
||||
|
||||
pthread_mutex_lock(&(sem->mutex));
|
||||
while(sem->c <= 0) {
|
||||
if(timeout > 0) {
|
||||
time = cond_wait(&(sem->cond), &(sem->mutex), timeout);
|
||||
|
||||
if(time == 0) {
|
||||
pthread_mutex_unlock(&(sem->mutex));
|
||||
return 0;
|
||||
}
|
||||
/* pthread_mutex_unlock(&(sem->mutex));
|
||||
return time; */
|
||||
} else {
|
||||
cond_wait(&(sem->cond), &(sem->mutex), 0);
|
||||
}
|
||||
}
|
||||
sem->c--;
|
||||
pthread_mutex_unlock(&(sem->mutex));
|
||||
return time;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_sem_signal(struct sys_sem *sem)
|
||||
{
|
||||
pthread_mutex_lock(&(sem->mutex));
|
||||
sem->c++;
|
||||
|
||||
if(sem->c > 1) {
|
||||
sem->c = 1;
|
||||
}
|
||||
|
||||
pthread_cond_broadcast(&(sem->cond));
|
||||
pthread_mutex_unlock(&(sem->mutex));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_sem_free(struct sys_sem *sem)
|
||||
{
|
||||
if(sem != SYS_SEM_NULL) {
|
||||
#ifdef SYS_STATS
|
||||
stats.sys.sem.used--;
|
||||
#endif /* SYS_STATS */
|
||||
sys_sem_free_(sem);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
sys_sem_free_(struct sys_sem *sem)
|
||||
{
|
||||
pthread_cond_destroy(&(sem->cond));
|
||||
pthread_mutex_destroy(&(sem->mutex));
|
||||
free(sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
unsigned long
|
||||
sys_unix_now()
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
long sec, usec;
|
||||
unsigned long msec;
|
||||
gettimeofday(&tv, &tz);
|
||||
|
||||
sec = tv.tv_sec - starttime.tv_sec;
|
||||
usec = tv.tv_usec - starttime.tv_usec;
|
||||
msec = sec * 1000 + usec / 1000;
|
||||
|
||||
return msec;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
sys_init()
|
||||
{
|
||||
struct timezone tz;
|
||||
gettimeofday(&starttime, &tz);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
struct sys_timeouts *
|
||||
sys_arch_timeouts(void)
|
||||
{
|
||||
struct sys_thread *thread;
|
||||
|
||||
thread = current_thread();
|
||||
return &thread->timeouts;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
1633
src/core/dhcp.c
Normal file
1633
src/core/dhcp.c
Normal file
File diff suppressed because it is too large
Load Diff
980
src/core/dns.c
Normal file
980
src/core/dns.c
Normal file
@@ -0,0 +1,980 @@
|
||||
/**
|
||||
* @file
|
||||
* DNS - host name to IP address resolver.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* This file implements a DNS host name to IP address resolver.
|
||||
|
||||
* Port to lwIP from uIP
|
||||
* by Jim Pettinato April 2007
|
||||
|
||||
* uIP version Copyright (c) 2002-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* DNS.C
|
||||
*
|
||||
* The lwIP DNS resolver functions are used to lookup a host name and
|
||||
* map it to a numerical IP address. It maintains a list of resolved
|
||||
* hostnames that can be queried with the dns_lookup() function.
|
||||
* New hostnames can be resolved using the dns_query() function.
|
||||
*
|
||||
* The lwIP version of the resolver also adds a non-blocking version of
|
||||
* gethostbyname() that will work with a raw API application. This function
|
||||
* checks for an IP address string first and converts it if it is valid.
|
||||
* gethostbyname() then does a dns_lookup() to see if the name is
|
||||
* already in the table. If so, the IP is returned. If not, a query is
|
||||
* issued and the function returns with a ERR_INPROGRESS status. The app
|
||||
* using the dns client must then go into a waiting state.
|
||||
*
|
||||
* Once a hostname has been resolved (or found to be non-existent),
|
||||
* the resolver code calls a specified callback function (which
|
||||
* must be implemented by the module that uses the resolver).
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* RFC 1035 - Domain names - implementation and specification
|
||||
* RFC 2181 - Clarifications to the DNS Specification
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** @todo: define good default values (rfc compliance) */
|
||||
/** @todo: improve answer parsing, more checkings... */
|
||||
/** @todo: check RFC1035 - 7.3. Processing responses */
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Includes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/dns.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/** DNS server IP address */
|
||||
#ifndef DNS_SERVER_ADDRESS
|
||||
#define DNS_SERVER_ADDRESS inet_addr("208.67.222.222") /* resolver1.opendns.com */
|
||||
#endif
|
||||
|
||||
/** DNS server port address */
|
||||
#ifndef DNS_SERVER_PORT
|
||||
#define DNS_SERVER_PORT 53
|
||||
#endif
|
||||
|
||||
/** DNS maximum number of retries when asking for a name, before "timeout". */
|
||||
#ifndef DNS_MAX_RETRIES
|
||||
#define DNS_MAX_RETRIES 4
|
||||
#endif
|
||||
|
||||
/** DNS resource record max. TTL (one week as default) */
|
||||
#ifndef DNS_MAX_TTL
|
||||
#define DNS_MAX_TTL 604800
|
||||
#endif
|
||||
|
||||
/* DNS protocol flags */
|
||||
#define DNS_FLAG1_RESPONSE 0x80
|
||||
#define DNS_FLAG1_OPCODE_STATUS 0x10
|
||||
#define DNS_FLAG1_OPCODE_INVERSE 0x08
|
||||
#define DNS_FLAG1_OPCODE_STANDARD 0x00
|
||||
#define DNS_FLAG1_AUTHORATIVE 0x04
|
||||
#define DNS_FLAG1_TRUNC 0x02
|
||||
#define DNS_FLAG1_RD 0x01
|
||||
#define DNS_FLAG2_RA 0x80
|
||||
#define DNS_FLAG2_ERR_MASK 0x0f
|
||||
#define DNS_FLAG2_ERR_NONE 0x00
|
||||
#define DNS_FLAG2_ERR_NAME 0x03
|
||||
|
||||
/* DNS protocol states */
|
||||
#define DNS_STATE_UNUSED 0
|
||||
#define DNS_STATE_NEW 1
|
||||
#define DNS_STATE_ASKING 2
|
||||
#define DNS_STATE_DONE 3
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** DNS message header */
|
||||
struct dns_hdr {
|
||||
PACK_STRUCT_FIELD(u16_t id);
|
||||
PACK_STRUCT_FIELD(u8_t flags1);
|
||||
PACK_STRUCT_FIELD(u8_t flags2);
|
||||
PACK_STRUCT_FIELD(u16_t numquestions);
|
||||
PACK_STRUCT_FIELD(u16_t numanswers);
|
||||
PACK_STRUCT_FIELD(u16_t numauthrr);
|
||||
PACK_STRUCT_FIELD(u16_t numextrarr);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
#define SIZEOF_DNS_HDR 12
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** DNS query message structure */
|
||||
struct dns_query {
|
||||
/* DNS query record starts with either a domain name or a pointer
|
||||
to a name already present somewhere in the packet. */
|
||||
PACK_STRUCT_FIELD(u16_t type);
|
||||
PACK_STRUCT_FIELD(u16_t class);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
#define SIZEOF_DNS_QUERY 4
|
||||
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/bpstruct.h"
|
||||
#endif
|
||||
PACK_STRUCT_BEGIN
|
||||
/** DNS answer message structure */
|
||||
struct dns_answer {
|
||||
/* DNS answer record starts with either a domain name or a pointer
|
||||
to a name already present somewhere in the packet. */
|
||||
PACK_STRUCT_FIELD(u16_t type);
|
||||
PACK_STRUCT_FIELD(u16_t class);
|
||||
PACK_STRUCT_FIELD(u32_t ttl);
|
||||
PACK_STRUCT_FIELD(u16_t len);
|
||||
} PACK_STRUCT_STRUCT;
|
||||
PACK_STRUCT_END
|
||||
#ifdef PACK_STRUCT_USE_INCLUDES
|
||||
# include "arch/epstruct.h"
|
||||
#endif
|
||||
#define SIZEOF_DNS_ANSWER 10
|
||||
|
||||
/** DNS table entry */
|
||||
struct dns_table_entry {
|
||||
u8_t state;
|
||||
u8_t numdns;
|
||||
u8_t tmr;
|
||||
u8_t retries;
|
||||
u8_t seqno;
|
||||
u8_t err;
|
||||
u32_t ttl;
|
||||
char name[DNS_MAX_NAME_LENGTH];
|
||||
struct ip_addr ipaddr;
|
||||
/* pointer to callback on DNS query done */
|
||||
dns_found_callback found;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
/** struct used for local host-list */
|
||||
struct local_hostlist_entry {
|
||||
/** static hostname */
|
||||
const char *name;
|
||||
/** static host address in network byteorder */
|
||||
u32_t addr;
|
||||
struct local_hostlist_entry *next;
|
||||
};
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
/** Local host-list. For hostnames in this list, no
|
||||
* external name resolution is performed */
|
||||
static struct local_hostlist_entry *local_hostlist_dynamic;
|
||||
#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
|
||||
/** Defining this allows the local_hostlist_static to be placed in a different
|
||||
* linker section (e.g. FLASH) */
|
||||
#ifndef DNS_LOCAL_HOSTLIST_STORAGE_PRE
|
||||
#define DNS_LOCAL_HOSTLIST_STORAGE_PRE static
|
||||
#endif /* DNS_LOCAL_HOSTLIST_STORAGE_PRE */
|
||||
/** Defining this allows the local_hostlist_static to be placed in a different
|
||||
* linker section (e.g. FLASH) */
|
||||
#ifndef DNS_LOCAL_HOSTLIST_STORAGE_POST
|
||||
#define DNS_LOCAL_HOSTLIST_STORAGE_POST
|
||||
#endif /* DNS_LOCAL_HOSTLIST_STORAGE_POST */
|
||||
DNS_LOCAL_HOSTLIST_STORAGE_PRE struct local_hostlist_entry local_hostlist_static[]
|
||||
DNS_LOCAL_HOSTLIST_STORAGE_POST = DNS_LOCAL_HOSTLIST_INIT;
|
||||
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
|
||||
static void dns_init_local();
|
||||
#endif /* DNS_LOCAL_HOSTLIST */
|
||||
|
||||
|
||||
/* forward declarations */
|
||||
static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);
|
||||
static void dns_check_entries(void);
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
* Globales
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* DNS variables */
|
||||
static struct udp_pcb *dns_pcb;
|
||||
static u8_t dns_seqno;
|
||||
static struct dns_table_entry dns_table[DNS_TABLE_SIZE];
|
||||
static struct ip_addr dns_servers[DNS_MAX_SERVERS];
|
||||
|
||||
#if (DNS_USES_STATIC_BUF == 1)
|
||||
static u8_t dns_payload[DNS_MSG_SIZE];
|
||||
#endif /* (DNS_USES_STATIC_BUF == 1) */
|
||||
|
||||
/**
|
||||
* Initialize the resolver: set up the UDP pcb and configure the default server
|
||||
* (DNS_SERVER_ADDRESS).
|
||||
*/
|
||||
void
|
||||
dns_init()
|
||||
{
|
||||
struct ip_addr dnsserver;
|
||||
|
||||
/* initialize default DNS server address */
|
||||
dnsserver.addr = DNS_SERVER_ADDRESS;
|
||||
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_init: initializing\n"));
|
||||
|
||||
/* if dns client not yet initialized... */
|
||||
if (dns_pcb == NULL) {
|
||||
dns_pcb = udp_new();
|
||||
|
||||
if (dns_pcb != NULL) {
|
||||
/* initialize DNS table not needed (initialized to zero since it is a
|
||||
* global variable) */
|
||||
LWIP_ASSERT("For implicit initialization to work, DNS_STATE_UNUSED needs to be 0",
|
||||
DNS_STATE_UNUSED == 0);
|
||||
|
||||
/* initialize DNS client */
|
||||
udp_bind(dns_pcb, IP_ADDR_ANY, 0);
|
||||
udp_recv(dns_pcb, dns_recv, NULL);
|
||||
|
||||
/* initialize default DNS primary server */
|
||||
dns_setserver(0, &dnsserver);
|
||||
}
|
||||
}
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
dns_init_local();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize one of the DNS servers.
|
||||
*
|
||||
* @param numdns the index of the DNS server to set must be < DNS_MAX_SERVERS
|
||||
* @param dnsserver IP address of the DNS server to set
|
||||
*/
|
||||
void
|
||||
dns_setserver(u8_t numdns, struct ip_addr *dnsserver)
|
||||
{
|
||||
if ((numdns < DNS_MAX_SERVERS) && (dns_pcb != NULL) &&
|
||||
(dnsserver != NULL) && (dnsserver->addr !=0 )) {
|
||||
dns_servers[numdns] = (*dnsserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain one of the currently configured DNS server.
|
||||
*
|
||||
* @param numdns the index of the DNS server
|
||||
* @return IP address of the indexed DNS server or "ip_addr_any" if the DNS
|
||||
* server has not been configured.
|
||||
*/
|
||||
struct ip_addr
|
||||
dns_getserver(u8_t numdns)
|
||||
{
|
||||
if (numdns < DNS_MAX_SERVERS) {
|
||||
return dns_servers[numdns];
|
||||
} else {
|
||||
return *IP_ADDR_ANY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The DNS resolver client timer - handle retries and timeouts and should
|
||||
* be called every DNS_TMR_INTERVAL milliseconds (every second by default).
|
||||
*/
|
||||
void
|
||||
dns_tmr(void)
|
||||
{
|
||||
if (dns_pcb != NULL) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_tmr: dns_check_entries\n"));
|
||||
dns_check_entries();
|
||||
}
|
||||
}
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
static void
|
||||
dns_init_local()
|
||||
{
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT)
|
||||
int i;
|
||||
struct local_hostlist_entry *entry;
|
||||
/* Dynamic: copy entries from DNS_LOCAL_HOSTLIST_INIT to list */
|
||||
struct local_hostlist_entry local_hostlist_init[] = DNS_LOCAL_HOSTLIST_INIT;
|
||||
for (i = 0; i < sizeof(local_hostlist_init) / sizeof(struct local_hostlist_entry); i++) {
|
||||
entry = mem_malloc(sizeof(struct local_hostlist_entry));
|
||||
LWIP_ASSERT("mem-error in dns_init_local", entry != NULL);
|
||||
if (entry != NULL) {
|
||||
struct local_hostlist_entry *init_entry = &local_hostlist_init[i];
|
||||
entry->name = init_entry->name;
|
||||
entry->addr = init_entry->addr;
|
||||
entry->next = local_hostlist_dynamic;
|
||||
local_hostlist_dynamic = entry;
|
||||
}
|
||||
}
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC && defined(DNS_LOCAL_HOSTLIST_INIT) */
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans the local host-list for a hostname.
|
||||
*
|
||||
* @param hostname Hostname to look for in the local host-list
|
||||
* @return The first IP address for the hostname in the local host-list or
|
||||
* INADDR_NONE if not found.
|
||||
*/
|
||||
static u32_t
|
||||
dns_lookup_local(const char *hostname)
|
||||
{
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
struct local_hostlist_entry *entry = local_hostlist_dynamic;
|
||||
while(entry != NULL) {
|
||||
if(strcmp(entry->name, hostname) == 0) {
|
||||
return entry->addr;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
#else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
int i;
|
||||
for (i = 0; i < sizeof(local_hostlist_static) / sizeof(struct local_hostlist_entry); i++) {
|
||||
if(strcmp(local_hostlist_static[i].name, hostname) == 0) {
|
||||
return local_hostlist_static[i].addr;
|
||||
}
|
||||
}
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
|
||||
return INADDR_NONE;
|
||||
}
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
|
||||
/** Remove all entries from the local host-list for a specific hostname
|
||||
* and/or IP addess
|
||||
*
|
||||
* @param hostname hostname for which entries shall be removed from the local
|
||||
* host-list
|
||||
* @param addr address for which entries shall be removed from the local host-list
|
||||
* @return the number of removed entries
|
||||
*/
|
||||
int
|
||||
dns_local_removehost(const char *hostname, const struct ip_addr *addr)
|
||||
{
|
||||
int removed = 0;
|
||||
struct local_hostlist_entry *entry = local_hostlist_dynamic;
|
||||
struct local_hostlist_entry *last_entry = NULL;
|
||||
while (entry != NULL) {
|
||||
if (((hostname == NULL) || !strcmp(entry->name, hostname)) &&
|
||||
((addr == NULL) || (entry->addr == addr->addr))) {
|
||||
struct local_hostlist_entry *free_entry;
|
||||
if (last_entry != NULL) {
|
||||
last_entry->next = entry->next;
|
||||
} else {
|
||||
local_hostlist_dynamic = entry->next;
|
||||
}
|
||||
free_entry = entry;
|
||||
entry = entry->next;
|
||||
mem_free(free_entry);
|
||||
removed++;
|
||||
} else {
|
||||
last_entry = entry;
|
||||
entry = entry->next;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a hostname/IP address pair to the local host-list.
|
||||
* Duplicates are not checked.
|
||||
*
|
||||
* @param hostname hostname of the new entry
|
||||
* @param addr IP address of the new entry
|
||||
* @return ERR_OK if succeeded or ERR_MEM on memory error
|
||||
*/
|
||||
err_t
|
||||
dns_local_addhost(const char *hostname, const struct ip_addr *addr)
|
||||
{
|
||||
struct local_hostlist_entry *entry;
|
||||
entry = mem_malloc(sizeof(struct local_hostlist_entry));
|
||||
if (entry == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
entry->name = hostname;
|
||||
entry->addr = addr->addr;
|
||||
entry->next = local_hostlist_dynamic;
|
||||
local_hostlist_dynamic = entry;
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC*/
|
||||
#endif /* DNS_LOCAL_HOSTLIST */
|
||||
|
||||
/**
|
||||
* Look up a hostname in the array of known hostnames.
|
||||
*
|
||||
* @note This function only looks in the internal array of known
|
||||
* hostnames, it does not send out a query for the hostname if none
|
||||
* was found. The function dns_enqueue() can be used to send a query
|
||||
* for a hostname.
|
||||
*
|
||||
* @param name the hostname to look up
|
||||
* @return the hostname's IP address, as u32_t (instead of struct ip_addr to
|
||||
* better check for failure: != INADDR_NONE) or INADDR_NONE if the hostname
|
||||
* was not found in the cached dns_table.
|
||||
*/
|
||||
static u32_t
|
||||
dns_lookup(const char *name)
|
||||
{
|
||||
u8_t i;
|
||||
#if DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN)
|
||||
u32_t addr;
|
||||
#endif /* DNS_LOCAL_HOSTLIST || defined(DNS_LOOKUP_LOCAL_EXTERN) */
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
if ((addr = dns_lookup_local(name)) != INADDR_NONE) {
|
||||
return addr;
|
||||
}
|
||||
#endif /* DNS_LOCAL_HOSTLIST */
|
||||
#ifdef DNS_LOOKUP_LOCAL_EXTERN
|
||||
if((addr = DNS_LOOKUP_LOCAL_EXTERN(name)) != INADDR_NONE) {
|
||||
return addr;
|
||||
}
|
||||
#endif /* DNS_LOOKUP_LOCAL_EXTERN */
|
||||
|
||||
/* Walk through name list, return entry if found. If not, return NULL. */
|
||||
for (i = 0; i < DNS_TABLE_SIZE; ++i) {
|
||||
if ((dns_table[i].state == DNS_STATE_DONE) &&
|
||||
(strcmp(name, dns_table[i].name) == 0)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_lookup: \"%s\": found = ", name));
|
||||
ip_addr_debug_print(DNS_DEBUG, &(dns_table[i].ipaddr));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("\n"));
|
||||
return dns_table[i].ipaddr.addr;
|
||||
}
|
||||
}
|
||||
|
||||
return INADDR_NONE;
|
||||
}
|
||||
|
||||
#if DNS_DOES_NAME_CHECK
|
||||
/**
|
||||
* Compare the "dotted" name "query" with the encoded name "response"
|
||||
* to make sure an answer from the DNS server matches the current dns_table
|
||||
* entry (otherwise, answers might arrive late for hostname not on the list
|
||||
* any more).
|
||||
*
|
||||
* @param query hostname (not encoded) from the dns_table
|
||||
* @param response encoded hostname in the DNS response
|
||||
* @return 0: names equal; 1: names differ
|
||||
*/
|
||||
static u8_t
|
||||
dns_compare_name(unsigned char *query, unsigned char *response)
|
||||
{
|
||||
unsigned char n;
|
||||
|
||||
do {
|
||||
n = *response++;
|
||||
/** @see RFC 1035 - 4.1.4. Message compression */
|
||||
if ((n & 0xc0) == 0xc0) {
|
||||
/* Compressed name */
|
||||
break;
|
||||
} else {
|
||||
/* Not compressed name */
|
||||
while (n > 0) {
|
||||
if ((*query) != (*response)) {
|
||||
return 1;
|
||||
}
|
||||
++response;
|
||||
++query;
|
||||
--n;
|
||||
};
|
||||
++query;
|
||||
}
|
||||
} while (*response != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* DNS_DOES_NAME_CHECK */
|
||||
|
||||
/**
|
||||
* Walk through a compact encoded DNS name and return the end of the name.
|
||||
*
|
||||
* @param query encoded DNS name in the DNS server response
|
||||
* @return end of the name
|
||||
*/
|
||||
static unsigned char *
|
||||
dns_parse_name(unsigned char *query)
|
||||
{
|
||||
unsigned char n;
|
||||
|
||||
do {
|
||||
n = *query++;
|
||||
/** @see RFC 1035 - 4.1.4. Message compression */
|
||||
if ((n & 0xc0) == 0xc0) {
|
||||
/* Compressed name */
|
||||
break;
|
||||
} else {
|
||||
/* Not compressed name */
|
||||
while (n > 0) {
|
||||
++query;
|
||||
--n;
|
||||
};
|
||||
}
|
||||
} while (*query != 0);
|
||||
|
||||
return query + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a DNS query packet.
|
||||
*
|
||||
* @param numdns index of the DNS server in the dns_servers table
|
||||
* @param name hostname to query
|
||||
* @param id index of the hostname in dns_table, used as transaction ID in the
|
||||
* DNS query packet
|
||||
* @return ERR_OK if packet is sent; an err_t indicating the problem otherwise
|
||||
*/
|
||||
static err_t
|
||||
dns_send(u8_t numdns, const char* name, u8_t id)
|
||||
{
|
||||
err_t err;
|
||||
struct dns_hdr *hdr;
|
||||
struct dns_query qry;
|
||||
struct pbuf *p;
|
||||
char *query, *nptr;
|
||||
const char *pHostname;
|
||||
u8_t n;
|
||||
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_send: dns_servers[%"U16_F"] \"%s\": request\n",
|
||||
(u16_t)(numdns), name));
|
||||
LWIP_ASSERT("dns server out of array", numdns < DNS_MAX_SERVERS);
|
||||
LWIP_ASSERT("dns server has no IP address set", dns_servers[numdns].addr != 0);
|
||||
|
||||
/* if here, we have either a new query or a retry on a previous query to process */
|
||||
p = pbuf_alloc(PBUF_TRANSPORT, SIZEOF_DNS_HDR + DNS_MAX_NAME_LENGTH +
|
||||
SIZEOF_DNS_QUERY, PBUF_RAM);
|
||||
if (p != NULL) {
|
||||
LWIP_ASSERT("pbuf must be in one piece", p->next == NULL);
|
||||
/* fill dns header */
|
||||
hdr = (struct dns_hdr*)p->payload;
|
||||
memset(hdr, 0, SIZEOF_DNS_HDR);
|
||||
hdr->id = htons(id);
|
||||
hdr->flags1 = DNS_FLAG1_RD;
|
||||
hdr->numquestions = htons(1);
|
||||
query = (char*)hdr + SIZEOF_DNS_HDR;
|
||||
pHostname = name;
|
||||
--pHostname;
|
||||
|
||||
/* convert hostname into suitable query format. */
|
||||
do {
|
||||
++pHostname;
|
||||
nptr = query;
|
||||
++query;
|
||||
for(n = 0; *pHostname != '.' && *pHostname != 0; ++pHostname) {
|
||||
*query = *pHostname;
|
||||
++query;
|
||||
++n;
|
||||
}
|
||||
*nptr = n;
|
||||
} while(*pHostname != 0);
|
||||
*query++='\0';
|
||||
|
||||
/* fill dns query */
|
||||
qry.type = htons(DNS_RRTYPE_A);
|
||||
qry.class = htons(DNS_RRCLASS_IN);
|
||||
MEMCPY( query, &qry, SIZEOF_DNS_QUERY);
|
||||
|
||||
/* resize pbuf to the exact dns query */
|
||||
pbuf_realloc(p, (query + SIZEOF_DNS_QUERY) - ((char*)(p->payload)));
|
||||
|
||||
/* connect to the server for faster receiving */
|
||||
udp_connect(dns_pcb, &dns_servers[numdns], DNS_SERVER_PORT);
|
||||
/* send dns packet */
|
||||
err = udp_sendto(dns_pcb, p, &dns_servers[numdns], DNS_SERVER_PORT);
|
||||
|
||||
/* free pbuf */
|
||||
pbuf_free(p);
|
||||
} else {
|
||||
err = ERR_MEM;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* dns_check_entry() - see if pEntry has not yet been queried and, if so, sends out a query.
|
||||
* Check an entry in the dns_table:
|
||||
* - send out query for new entries
|
||||
* - retry old pending entries on timeout (also with different servers)
|
||||
* - remove completed entries from the table if their TTL has expired
|
||||
*
|
||||
* @param i index of the dns_table entry to check
|
||||
*/
|
||||
static void
|
||||
dns_check_entry(u8_t i)
|
||||
{
|
||||
struct dns_table_entry *pEntry = &dns_table[i];
|
||||
|
||||
LWIP_ASSERT("array index out of bounds", i < DNS_TABLE_SIZE);
|
||||
|
||||
switch(pEntry->state) {
|
||||
|
||||
case DNS_STATE_NEW: {
|
||||
/* initialize new entry */
|
||||
pEntry->state = DNS_STATE_ASKING;
|
||||
pEntry->numdns = 0;
|
||||
pEntry->tmr = 1;
|
||||
pEntry->retries = 0;
|
||||
|
||||
/* send DNS packet for this entry */
|
||||
dns_send(pEntry->numdns, pEntry->name, i);
|
||||
break;
|
||||
}
|
||||
|
||||
case DNS_STATE_ASKING: {
|
||||
if (--pEntry->tmr == 0) {
|
||||
if (++pEntry->retries == DNS_MAX_RETRIES) {
|
||||
if ((pEntry->numdns+1<DNS_MAX_SERVERS) && (dns_servers[pEntry->numdns+1].addr!=0)) {
|
||||
/* change of server */
|
||||
pEntry->numdns++;
|
||||
pEntry->tmr = 1;
|
||||
pEntry->retries = 0;
|
||||
break;
|
||||
} else {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": timeout\n", pEntry->name));
|
||||
/* call specified callback function if provided */
|
||||
if (pEntry->found)
|
||||
(*pEntry->found)(pEntry->name, NULL, pEntry->arg);
|
||||
/* flush this entry */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
pEntry->found = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* wait longer for the next retry */
|
||||
pEntry->tmr = pEntry->retries;
|
||||
|
||||
/* send DNS packet for this entry */
|
||||
dns_send(pEntry->numdns, pEntry->name, i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DNS_STATE_DONE: {
|
||||
/* if the time to live is nul */
|
||||
if (--pEntry->ttl == 0) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_check_entry: \"%s\": flush\n", pEntry->name));
|
||||
/* flush this entry */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
pEntry->found = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DNS_STATE_UNUSED:
|
||||
/* nothing to do */
|
||||
break;
|
||||
default:
|
||||
LWIP_ASSERT("unknown dns_table entry state:", 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call dns_check_entry for each entry in dns_table - check all entries.
|
||||
*/
|
||||
static void
|
||||
dns_check_entries(void)
|
||||
{
|
||||
u8_t i;
|
||||
|
||||
for (i = 0; i < DNS_TABLE_SIZE; ++i) {
|
||||
dns_check_entry(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive input function for DNS response packets arriving for the dns UDP pcb.
|
||||
*
|
||||
* @params see udp.h
|
||||
*/
|
||||
static void
|
||||
dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
|
||||
{
|
||||
u8_t i;
|
||||
char *pHostname;
|
||||
struct dns_hdr *hdr;
|
||||
struct dns_answer ans;
|
||||
struct dns_table_entry *pEntry;
|
||||
u8_t nquestions, nanswers;
|
||||
#if (DNS_USES_STATIC_BUF == 0)
|
||||
u8_t dns_payload[DNS_MSG_SIZE];
|
||||
#endif /* (DNS_USES_STATIC_BUF == 0) */
|
||||
#if (DNS_USES_STATIC_BUF == 2)
|
||||
u8_t* dns_payload;
|
||||
#endif /* (DNS_USES_STATIC_BUF == 2) */
|
||||
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
LWIP_UNUSED_ARG(pcb);
|
||||
LWIP_UNUSED_ARG(addr);
|
||||
LWIP_UNUSED_ARG(port);
|
||||
|
||||
/* is the dns message too big ? */
|
||||
if (p->tot_len > DNS_MSG_SIZE) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too big\n"));
|
||||
/* free pbuf and return */
|
||||
goto memerr1;
|
||||
}
|
||||
|
||||
/* is the dns message big enough ? */
|
||||
if (p->tot_len < (SIZEOF_DNS_HDR + SIZEOF_DNS_QUERY + SIZEOF_DNS_ANSWER)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: pbuf too small\n"));
|
||||
/* free pbuf and return */
|
||||
goto memerr1;
|
||||
}
|
||||
|
||||
#if (DNS_USES_STATIC_BUF == 2)
|
||||
dns_payload = mem_malloc(p->tot_len);
|
||||
if (dns_payload == NULL) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: mem_malloc error\n"));
|
||||
/* free pbuf and return */
|
||||
goto memerr1;
|
||||
}
|
||||
#endif /* (DNS_USES_STATIC_BUF == 2) */
|
||||
|
||||
/* copy dns payload inside static buffer for processing */
|
||||
if (pbuf_copy_partial(p, dns_payload, p->tot_len, 0) == p->tot_len) {
|
||||
/* The ID in the DNS header should be our entry into the name table. */
|
||||
hdr = (struct dns_hdr*)dns_payload;
|
||||
i = htons(hdr->id);
|
||||
if (i < DNS_TABLE_SIZE) {
|
||||
pEntry = &dns_table[i];
|
||||
if(pEntry->state == DNS_STATE_ASKING) {
|
||||
/* This entry is now completed. */
|
||||
pEntry->state = DNS_STATE_DONE;
|
||||
pEntry->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
|
||||
|
||||
/* We only care about the question(s) and the answers. The authrr
|
||||
and the extrarr are simply discarded. */
|
||||
nquestions = htons(hdr->numquestions);
|
||||
nanswers = htons(hdr->numanswers);
|
||||
|
||||
/* Check for error. If so, call callback to inform. */
|
||||
if (((hdr->flags1 & DNS_FLAG1_RESPONSE) == 0) || (pEntry->err != 0) || (nquestions != 1)) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in flags\n", pEntry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
|
||||
#if DNS_DOES_NAME_CHECK
|
||||
/* Check if the name in the "question" part match with the name in the entry. */
|
||||
if (dns_compare_name((unsigned char *)(pEntry->name), (unsigned char *)dns_payload + SIZEOF_DNS_HDR) != 0) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response not match to query\n", pEntry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
#endif /* DNS_DOES_NAME_CHECK */
|
||||
|
||||
/* Skip the name in the "question" part */
|
||||
pHostname = (char *) dns_parse_name((unsigned char *)dns_payload + SIZEOF_DNS_HDR) + SIZEOF_DNS_QUERY;
|
||||
|
||||
while(nanswers > 0) {
|
||||
/* skip answer resource record's host name */
|
||||
pHostname = (char *) dns_parse_name((unsigned char *)pHostname);
|
||||
|
||||
/* Check for IP address type and Internet class. Others are discarded. */
|
||||
MEMCPY(&ans, pHostname, SIZEOF_DNS_ANSWER);
|
||||
if((ntohs(ans.type) == DNS_RRTYPE_A) && (ntohs(ans.class) == DNS_RRCLASS_IN) && (ntohs(ans.len) == sizeof(struct ip_addr)) ) {
|
||||
/* read the answer resource record's TTL, and maximize it if needed */
|
||||
pEntry->ttl = ntohl(ans.ttl);
|
||||
if (pEntry->ttl > DNS_MAX_TTL) {
|
||||
pEntry->ttl = DNS_MAX_TTL;
|
||||
}
|
||||
/* read the IP address after answer resource record's header */
|
||||
MEMCPY( &(pEntry->ipaddr), (pHostname+SIZEOF_DNS_ANSWER), sizeof(struct ip_addr));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": response = ", pEntry->name));
|
||||
ip_addr_debug_print(DNS_DEBUG, (&(pEntry->ipaddr)));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("\n"));
|
||||
/* call specified callback function if provided */
|
||||
if (pEntry->found) {
|
||||
(*pEntry->found)(pEntry->name, &pEntry->ipaddr, pEntry->arg);
|
||||
}
|
||||
/* deallocate memory and return */
|
||||
goto memerr2;
|
||||
} else {
|
||||
pHostname = pHostname + SIZEOF_DNS_ANSWER + htons(ans.len);
|
||||
}
|
||||
--nanswers;
|
||||
}
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_recv: \"%s\": error in response\n", pEntry->name));
|
||||
/* call callback to indicate error, clean up memory and return */
|
||||
goto responseerr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* deallocate memory and return */
|
||||
goto memerr2;
|
||||
|
||||
responseerr:
|
||||
/* ERROR: call specified callback function with NULL as name to indicate an error */
|
||||
if (pEntry->found) {
|
||||
(*pEntry->found)(pEntry->name, NULL, pEntry->arg);
|
||||
}
|
||||
/* flush this entry */
|
||||
pEntry->state = DNS_STATE_UNUSED;
|
||||
pEntry->found = NULL;
|
||||
|
||||
memerr2:
|
||||
#if (DNS_USES_STATIC_BUF == 2)
|
||||
/* free dns buffer */
|
||||
mem_free(dns_payload);
|
||||
#endif /* (DNS_USES_STATIC_BUF == 2) */
|
||||
|
||||
memerr1:
|
||||
/* free pbuf */
|
||||
pbuf_free(p);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues a new hostname to resolve and sends out a DNS query for that hostname
|
||||
*
|
||||
* @param name the hostname that is to be queried
|
||||
* @param found a callback founction to be called on success, failure or timeout
|
||||
* @param callback_arg argument to pass to the callback function
|
||||
* @return @return a err_t return code.
|
||||
*/
|
||||
static err_t
|
||||
dns_enqueue(const char *name, dns_found_callback found, void *callback_arg)
|
||||
{
|
||||
u8_t i;
|
||||
u8_t lseq, lseqi;
|
||||
struct dns_table_entry *pEntry = NULL;
|
||||
|
||||
/* search an unused entry, or the oldest one */
|
||||
lseq = lseqi = 0;
|
||||
for (i = 0; i < DNS_TABLE_SIZE; ++i) {
|
||||
pEntry = &dns_table[i];
|
||||
/* is it an unused entry ? */
|
||||
if (pEntry->state == DNS_STATE_UNUSED)
|
||||
break;
|
||||
|
||||
/* check if this is the oldest completed entry */
|
||||
if (pEntry->state == DNS_STATE_DONE) {
|
||||
if ((dns_seqno - pEntry->seqno) > lseq) {
|
||||
lseq = dns_seqno - pEntry->seqno;
|
||||
lseqi = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if we don't have found an unused entry, use the oldest completed one */
|
||||
if (i == DNS_TABLE_SIZE) {
|
||||
if ((lseqi >= DNS_TABLE_SIZE) || (dns_table[lseqi].state != DNS_STATE_DONE)) {
|
||||
/* no entry can't be used now, table is full */
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": DNS entries table is full\n", name));
|
||||
return ERR_MEM;
|
||||
} else {
|
||||
/* use the oldest completed one */
|
||||
i = lseqi;
|
||||
pEntry = &dns_table[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* use this entry */
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_enqueue: \"%s\": use DNS entry %"U16_F"\n", name, (u16_t)(i)));
|
||||
|
||||
/* fill the entry */
|
||||
pEntry->state = DNS_STATE_NEW;
|
||||
pEntry->seqno = dns_seqno++;
|
||||
pEntry->found = found;
|
||||
pEntry->arg = callback_arg;
|
||||
strcpy(pEntry->name, name);
|
||||
|
||||
/* force to send query without waiting timer */
|
||||
dns_check_entry(i);
|
||||
|
||||
/* dns query is enqueued */
|
||||
return ERR_INPROGRESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a hostname (string) into an IP address.
|
||||
* NON-BLOCKING callback version for use with raw API!!!
|
||||
*
|
||||
* Returns immediately with one of err_t return codes:
|
||||
* - ERR_OK if hostname is a valid IP address string or the host
|
||||
* name is already in the local names table.
|
||||
* - ERR_INPROGRESS enqueue a request to be sent to the DNS server
|
||||
* for resolution if no errors are present.
|
||||
*
|
||||
* @param hostname the hostname that is to be queried
|
||||
* @param addr pointer to a struct ip_addr where to store the address if it is already
|
||||
* cached in the dns_table (only valid if ERR_OK is returned!)
|
||||
* @param found a callback function to be called on success, failure or timeout (only if
|
||||
* ERR_INPROGRESS is returned!)
|
||||
* @param callback_arg argument to pass to the callback function
|
||||
* @return a err_t return code.
|
||||
*/
|
||||
err_t
|
||||
dns_gethostbyname(const char *hostname, struct ip_addr *addr, dns_found_callback found,
|
||||
void *callback_arg)
|
||||
{
|
||||
/* not initialized or no valid server yet, or invalid addr pointer
|
||||
* or invalid hostname or invalid hostname length */
|
||||
if ((dns_pcb == NULL) || (addr == NULL) ||
|
||||
(!hostname) || (!hostname[0]) ||
|
||||
(strlen(hostname) >= DNS_MAX_NAME_LENGTH)) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#if LWIP_HAVE_LOOPIF
|
||||
if (strcmp(hostname,"localhost")==0) {
|
||||
addr->addr = INADDR_LOOPBACK;
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* LWIP_HAVE_LOOPIF */
|
||||
|
||||
/* host name already in octet notation? set ip addr and return ERR_OK
|
||||
* already have this address cached? */
|
||||
if (((addr->addr = inet_addr(hostname)) != INADDR_NONE) ||
|
||||
((addr->addr = dns_lookup(hostname)) != INADDR_NONE)) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/* queue query with specified callback */
|
||||
return dns_enqueue(hostname, found, callback_arg);
|
||||
}
|
||||
|
||||
#endif /* LWIP_DNS */
|
||||
162
src/core/inet.c
162
src/core/inet.c
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* inet.c
|
||||
*
|
||||
* Functions common to all TCP/IP modules, such as the Internet checksum and the
|
||||
* byte order functions.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/arch.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/inet.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static u16_t
|
||||
lwip_chksum(void *dataptr, int len)
|
||||
{
|
||||
u32_t acc;
|
||||
|
||||
for(acc = 0; len > 1; len -= 2) {
|
||||
acc += *((u16_t *)dataptr)++;
|
||||
}
|
||||
|
||||
/* add up any odd byte */
|
||||
if(len == 1) {
|
||||
acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8);
|
||||
DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", *(u8_t *)dataptr));
|
||||
}
|
||||
acc = (acc >> 16) + (acc & 0xffffUL);
|
||||
|
||||
if(acc & 0xffff0000 != 0) {
|
||||
acc = (acc >> 16) + (acc & 0xffffUL);
|
||||
}
|
||||
|
||||
return (u16_t)acc;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* inet_chksum_pseudo:
|
||||
*
|
||||
* Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
inet_chksum_pseudo(struct pbuf *p,
|
||||
struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t proto, u16_t proto_len)
|
||||
{
|
||||
u32_t acc;
|
||||
struct pbuf *q;
|
||||
u8_t swapped;
|
||||
|
||||
acc = 0;
|
||||
swapped = 0;
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
acc += lwip_chksum(q->payload, q->len);
|
||||
while(acc >> 16) {
|
||||
acc = (acc & 0xffffUL) + (acc >> 16);
|
||||
}
|
||||
if(q->len % 2 != 0) {
|
||||
swapped = 1 - swapped;
|
||||
acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
if(swapped) {
|
||||
acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
|
||||
}
|
||||
acc += (src->addr & 0xffffUL);
|
||||
acc += ((src->addr >> 16) & 0xffffUL);
|
||||
acc += (dest->addr & 0xffffUL);
|
||||
acc += ((dest->addr >> 16) & 0xffffUL);
|
||||
acc += (u32_t)htons((u16_t)proto);
|
||||
acc += (u32_t)htons(proto_len);
|
||||
|
||||
while(acc >> 16) {
|
||||
acc = (acc & 0xffffUL) + (acc >> 16);
|
||||
}
|
||||
return ~(acc & 0xffffUL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* inet_chksum:
|
||||
*
|
||||
* Calculates the Internet checksum over a portion of memory. Used primarely for IP
|
||||
* and ICMP.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
inet_chksum(void *dataptr, u16_t len)
|
||||
{
|
||||
u32_t acc;
|
||||
|
||||
acc = lwip_chksum(dataptr, len);
|
||||
while(acc >> 16) {
|
||||
acc = (acc & 0xffff) + (acc >> 16);
|
||||
}
|
||||
return ~(acc & 0xffff);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
inet_chksum_pbuf(struct pbuf *p)
|
||||
{
|
||||
u32_t acc;
|
||||
struct pbuf *q;
|
||||
u8_t swapped;
|
||||
|
||||
acc = 0;
|
||||
swapped = 0;
|
||||
for(q = p; q != NULL; q = q->next) {
|
||||
acc += lwip_chksum(q->payload, q->len);
|
||||
while(acc >> 16) {
|
||||
acc = (acc & 0xffff) + (acc >> 16);
|
||||
}
|
||||
if(q->len % 2 != 0) {
|
||||
swapped = 1 - swapped;
|
||||
acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
if(swapped) {
|
||||
acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
|
||||
}
|
||||
return ~(acc & 0xffff);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
269
src/core/init.c
Normal file
269
src/core/init.c
Normal file
@@ -0,0 +1,269 @@
|
||||
/**
|
||||
* @file
|
||||
* Modules initialization
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/init.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/snmp_msg.h"
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
/* Compile-time sanity checks for configuration errors.
|
||||
* These can be done independently of LWIP_DEBUG, without penalty.
|
||||
*/
|
||||
#ifndef BYTE_ORDER
|
||||
#error "BYTE_ORDER is not defined, you have to define it in your cc.h"
|
||||
#endif
|
||||
#if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV)
|
||||
#error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_ARP && ARP_QUEUEING)
|
||||
#error "If you want to use ARP Queueing, you have to define LWIP_ARP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_UDPLITE)
|
||||
#error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_SNMP)
|
||||
#error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_DHCP)
|
||||
#error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_IGMP)
|
||||
#error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_DNS)
|
||||
#error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f))
|
||||
#error "If you want to use ARP, ARP_TABLE_SIZE must fit in an s8_t, so, you have to reduce it in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0))
|
||||
#error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0))
|
||||
#error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0))
|
||||
#error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0))
|
||||
#error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && (TCP_WND > 0xffff))
|
||||
#error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
|
||||
#error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
|
||||
#error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))
|
||||
#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
|
||||
#endif
|
||||
#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1))
|
||||
#error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (PPP_SUPPORT && (NO_SYS==1))
|
||||
#error "If you want to use PPP, you have to define NO_SYS=0 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_NETIF_API && (NO_SYS==1))
|
||||
#error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h"
|
||||
#endif
|
||||
#if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1))
|
||||
#error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h"
|
||||
#endif
|
||||
#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0))
|
||||
#error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_NETCONN && LWIP_SOCKET)
|
||||
#error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP)
|
||||
#error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK)
|
||||
#error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_ARP && LWIP_AUTOIP)
|
||||
#error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0))
|
||||
#error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0))
|
||||
#error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
|
||||
#error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
|
||||
#endif
|
||||
/* There must be sufficient timeouts, taking into account requirements of the subsystems. */
|
||||
#if ((NO_SYS==0) && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT)))
|
||||
#error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts"
|
||||
#endif
|
||||
#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS))
|
||||
#error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!"
|
||||
#endif
|
||||
#if (MEM_LIBC_MALLOC && MEM_USE_POOLS)
|
||||
#error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h"
|
||||
#endif
|
||||
#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS)
|
||||
#error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h"
|
||||
#endif
|
||||
#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT)
|
||||
#error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf"
|
||||
#endif
|
||||
#if (TCP_QUEUE_OOSEQ && !LWIP_TCP)
|
||||
#error "TCP_QUEUE_OOSEQ requires LWIP_TCP"
|
||||
#endif
|
||||
#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
|
||||
#error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
|
||||
#endif
|
||||
|
||||
|
||||
/* Compile-time checks for deprecated options.
|
||||
*/
|
||||
#ifdef MEMP_NUM_TCPIP_MSG
|
||||
#error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h."
|
||||
#endif
|
||||
#ifdef MEMP_NUM_API_MSG
|
||||
#error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h."
|
||||
#endif
|
||||
#ifdef TCP_REXMIT_DEBUG
|
||||
#error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h."
|
||||
#endif
|
||||
#ifdef RAW_STATS
|
||||
#error "RAW_STATS option is deprecated. Remove it from your lwipopts.h."
|
||||
#endif
|
||||
#ifdef ETHARP_QUEUE_FIRST
|
||||
#error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h."
|
||||
#endif
|
||||
#ifdef ETHARP_ALWAYS_INSERT
|
||||
#error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h."
|
||||
#endif
|
||||
#if SO_REUSE
|
||||
/* I removed the lot since this was an ugly hack. It broke the raw-API.
|
||||
It also came with many ugly goto's, Christiaan Simons. */
|
||||
#error "SO_REUSE currently unavailable, this was a hack"
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
static void
|
||||
lwip_sanity_check(void)
|
||||
{
|
||||
/* Warnings */
|
||||
#if LWIP_NETCONN
|
||||
if (MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB))
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: MEMP_NUM_NETCONN should be less than the sum of MEMP_NUM_{TCP,RAW,UDP}_PCB+MEMP_NUM_TCP_PCB_LISTEN\n"));
|
||||
#endif /* LWIP_NETCONN */
|
||||
#if LWIP_TCP
|
||||
if (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN\n"));
|
||||
if (TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF/TCP_MSS)))
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work\n"));
|
||||
if (TCP_SNDLOWAT > TCP_SND_BUF)
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than or equal to TCP_SND_BUF.\n"));
|
||||
if (TCP_WND > (PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE))
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE*PBUF_POOL_BUFSIZE\n"));
|
||||
if (TCP_WND < TCP_MSS)
|
||||
LWIP_PLATFORM_DIAG(("lwip_sanity_check: WARNING: TCP_WND is smaller than MSS\n"));
|
||||
#endif /* LWIP_TCP */
|
||||
}
|
||||
#else /* LWIP_DEBUG */
|
||||
#define lwip_sanity_check()
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
/**
|
||||
* Perform Sanity check of user-configurable values, and initialize all modules.
|
||||
*/
|
||||
void
|
||||
lwip_init(void)
|
||||
{
|
||||
/* Sanity check user-configurable values */
|
||||
lwip_sanity_check();
|
||||
|
||||
/* Modules initialization */
|
||||
stats_init();
|
||||
sys_init();
|
||||
mem_init();
|
||||
memp_init();
|
||||
pbuf_init();
|
||||
netif_init();
|
||||
#if LWIP_SOCKET
|
||||
lwip_socket_init();
|
||||
#endif /* LWIP_SOCKET */
|
||||
ip_init();
|
||||
#if LWIP_ARP
|
||||
etharp_init();
|
||||
#endif /* LWIP_ARP */
|
||||
#if LWIP_RAW
|
||||
raw_init();
|
||||
#endif /* LWIP_RAW */
|
||||
#if LWIP_UDP
|
||||
udp_init();
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_TCP
|
||||
tcp_init();
|
||||
#endif /* LWIP_TCP */
|
||||
#if LWIP_SNMP
|
||||
snmp_init();
|
||||
#endif /* LWIP_SNMP */
|
||||
#if LWIP_AUTOIP
|
||||
autoip_init();
|
||||
#endif /* LWIP_AUTOIP */
|
||||
#if LWIP_IGMP
|
||||
igmp_init();
|
||||
#endif /* LWIP_IGMP */
|
||||
#if LWIP_DNS
|
||||
dns_init();
|
||||
#endif /* LWIP_DNS */
|
||||
}
|
||||
453
src/core/ipv4/autoip.c
Normal file
453
src/core/ipv4/autoip.c
Normal file
@@ -0,0 +1,453 @@
|
||||
/**
|
||||
* @file
|
||||
* AutoIP Automatic LinkLocal IP Configuration
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* Author: Dominik Spies <kontakt@dspies.de>
|
||||
*
|
||||
* This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
|
||||
* with RFC 3927.
|
||||
*
|
||||
*
|
||||
* Please coordinate changes and requests with Dominik Spies
|
||||
* <kontakt@dspies.de>
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* USAGE:
|
||||
*
|
||||
* define LWIP_AUTOIP 1 in your lwipopts.h
|
||||
*
|
||||
* If you don't use tcpip.c (so, don't call, you don't call tcpip_init):
|
||||
* - First, call autoip_init().
|
||||
* - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces,
|
||||
* that should be defined in autoip.h.
|
||||
* I recommend a value of 100. The value must divide 1000 with a remainder almost 0.
|
||||
* Possible values are 1000, 500, 333, 250, 200, 166, 142, 125, 111, 100 ....
|
||||
*
|
||||
* Without DHCP:
|
||||
* - Call autoip_start() after netif_add().
|
||||
*
|
||||
* With DHCP:
|
||||
* - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h.
|
||||
* - Configure your DHCP Client.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/autoip.h"
|
||||
#include "netif/etharp.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* 169.254.0.0 */
|
||||
#define AUTOIP_NET 0xA9FE0000
|
||||
/* 169.254.1.0 */
|
||||
#define AUTOIP_RANGE_START (AUTOIP_NET | 0x0100)
|
||||
/* 169.254.254.255 */
|
||||
#define AUTOIP_RANGE_END (AUTOIP_NET | 0xFEFF)
|
||||
|
||||
|
||||
/** Pseudo random macro based on netif informations.
|
||||
* You could use "rand()" from the C Library if you define LWIP_AUTOIP_RAND in lwipopts.h */
|
||||
#ifndef LWIP_AUTOIP_RAND
|
||||
#define LWIP_AUTOIP_RAND(netif) ( (((u32_t)((netif->hwaddr[5]) & 0xff) << 24) | \
|
||||
((u32_t)((netif->hwaddr[3]) & 0xff) << 16) | \
|
||||
((u32_t)((netif->hwaddr[2]) & 0xff) << 8) | \
|
||||
((u32_t)((netif->hwaddr[4]) & 0xff))) + \
|
||||
(netif->autoip?netif->autoip->tried_llipaddr:0))
|
||||
#endif /* LWIP_AUTOIP_RAND */
|
||||
|
||||
/**
|
||||
* Macro that generates the initial IP address to be tried by AUTOIP.
|
||||
* If you want to override this, define it to something else in lwipopts.h.
|
||||
*/
|
||||
#ifndef LWIP_AUTOIP_CREATE_SEED_ADDR
|
||||
#define LWIP_AUTOIP_CREATE_SEED_ADDR(netif) \
|
||||
(AUTOIP_RANGE_START + ((u32_t)(((u8_t)(netif->hwaddr[4])) | \
|
||||
((u32_t)((u8_t)(netif->hwaddr[5]))) << 8)))
|
||||
#endif /* LWIP_AUTOIP_CREATE_SEED_ADDR */
|
||||
|
||||
/* static functions */
|
||||
static void autoip_handle_arp_conflict(struct netif *netif);
|
||||
|
||||
/* creates a pseudo random LL IP-Address for a network interface */
|
||||
static void autoip_create_addr(struct netif *netif, struct ip_addr *IPAddr);
|
||||
|
||||
/* sends an ARP announce */
|
||||
static err_t autoip_arp_announce(struct netif *netif);
|
||||
|
||||
/* configure interface for use with current LL IP-Address */
|
||||
static err_t autoip_bind(struct netif *netif);
|
||||
|
||||
/**
|
||||
* Initialize this module
|
||||
*/
|
||||
void
|
||||
autoip_init(void)
|
||||
{
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | 3, ("autoip_init()\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a IP address conflict after an ARP conflict detection
|
||||
*/
|
||||
static void
|
||||
autoip_handle_arp_conflict(struct netif *netif)
|
||||
{
|
||||
/* Somehow detect if we are defending or retreating */
|
||||
unsigned char defend = 1; /* tbd */
|
||||
|
||||
if(defend) {
|
||||
if(netif->autoip->lastconflict > 0) {
|
||||
/* retreat, there was a conflicting ARP in the last
|
||||
* DEFEND_INTERVAL seconds
|
||||
*/
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
|
||||
("autoip_handle_arp_conflict(): we are defending, but in DEFEND_INTERVAL, retreating\n"));
|
||||
|
||||
/* TODO: close all TCP sessions */
|
||||
autoip_start(netif);
|
||||
} else {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
|
||||
("autoip_handle_arp_conflict(): we are defend, send ARP Announce\n"));
|
||||
autoip_arp_announce(netif);
|
||||
netif->autoip->lastconflict = DEFEND_INTERVAL * AUTOIP_TICKS_PER_SECOND;
|
||||
}
|
||||
} else {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
|
||||
("autoip_handle_arp_conflict(): we do not defend, retreating\n"));
|
||||
/* TODO: close all TCP sessions */
|
||||
autoip_start(netif);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an IP-Address out of range 169.254.1.0 to 169.254.254.255
|
||||
*
|
||||
* @param netif network interface on which create the IP-Address
|
||||
* @param IPAddr ip address to initialize
|
||||
*/
|
||||
static void
|
||||
autoip_create_addr(struct netif *netif, struct ip_addr *IPAddr)
|
||||
{
|
||||
/* Here we create an IP-Address out of range 169.254.1.0 to 169.254.254.255
|
||||
* compliant to RFC 3927 Section 2.1
|
||||
* We have 254 * 256 possibilities */
|
||||
|
||||
u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif));
|
||||
addr += netif->autoip->tried_llipaddr;
|
||||
addr = AUTOIP_NET | (addr & 0xffff);
|
||||
/* Now, 169.254.0.0 <= addr <= 169.254.255.255 */
|
||||
|
||||
if (addr < AUTOIP_RANGE_START) {
|
||||
addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
|
||||
}
|
||||
if (addr > AUTOIP_RANGE_END) {
|
||||
addr -= AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1;
|
||||
}
|
||||
LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) &&
|
||||
(addr <= AUTOIP_RANGE_END));
|
||||
IPAddr->addr = htonl(addr);
|
||||
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
|
||||
("autoip_create_addr(): tried_llipaddr=%"U16_F", 0x%08"X32_F"\n",
|
||||
(u16_t)(netif->autoip->tried_llipaddr), (u32_t)(IPAddr->addr)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an ARP announce from a network interface
|
||||
*
|
||||
* @param netif network interface used to send the announce
|
||||
*/
|
||||
static err_t
|
||||
autoip_arp_announce(struct netif *netif)
|
||||
{
|
||||
return etharp_raw(netif, (struct eth_addr *)netif->hwaddr, ðbroadcast,
|
||||
(struct eth_addr *)netif->hwaddr, &netif->autoip->llipaddr, ðzero,
|
||||
&netif->autoip->llipaddr, ARP_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure interface for use with current LL IP-Address
|
||||
*
|
||||
* @param netif network interface to configure with current LL IP-Address
|
||||
*/
|
||||
static err_t
|
||||
autoip_bind(struct netif *netif)
|
||||
{
|
||||
struct autoip *autoip = netif->autoip;
|
||||
struct ip_addr sn_mask, gw_addr;
|
||||
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | 3,
|
||||
("autoip_bind(netif=%p) %c%c%"U16_F" 0x%08"X32_F"\n",
|
||||
(void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num, autoip->llipaddr.addr));
|
||||
|
||||
IP4_ADDR(&sn_mask, 255, 255, 0, 0);
|
||||
IP4_ADDR(&gw_addr, 0, 0, 0, 0);
|
||||
|
||||
netif_set_ipaddr(netif, &autoip->llipaddr);
|
||||
netif_set_netmask(netif, &sn_mask);
|
||||
netif_set_gw(netif, &gw_addr);
|
||||
|
||||
/* bring the interface up */
|
||||
netif_set_up(netif);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start AutoIP client
|
||||
*
|
||||
* @param netif network interface on which start the AutoIP client
|
||||
*/
|
||||
err_t
|
||||
autoip_start(struct netif *netif)
|
||||
{
|
||||
struct autoip *autoip = netif->autoip;
|
||||
err_t result = ERR_OK;
|
||||
|
||||
if(netif_is_up(netif)) {
|
||||
netif_set_down(netif);
|
||||
}
|
||||
|
||||
/* Set IP-Address, Netmask and Gateway to 0 to make sure that
|
||||
* ARP Packets are formed correctly
|
||||
*/
|
||||
netif->ip_addr.addr = 0;
|
||||
netif->netmask.addr = 0;
|
||||
netif->gw.addr = 0;
|
||||
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
|
||||
("autoip_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0],
|
||||
netif->name[1], (u16_t)netif->num));
|
||||
if(autoip == NULL) {
|
||||
/* no AutoIP client attached yet? */
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
|
||||
("autoip_start(): starting new AUTOIP client\n"));
|
||||
autoip = mem_malloc(sizeof(struct autoip));
|
||||
if(autoip == NULL) {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
|
||||
("autoip_start(): could not allocate autoip\n"));
|
||||
return ERR_MEM;
|
||||
}
|
||||
memset( autoip, 0, sizeof(struct autoip));
|
||||
/* store this AutoIP client in the netif */
|
||||
netif->autoip = autoip;
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip"));
|
||||
} else {
|
||||
autoip->state = AUTOIP_STATE_OFF;
|
||||
autoip->ttw = 0;
|
||||
autoip->sent_num = 0;
|
||||
memset(&autoip->llipaddr, 0, sizeof(struct ip_addr));
|
||||
autoip->lastconflict = 0;
|
||||
}
|
||||
|
||||
autoip_create_addr(netif, &(autoip->llipaddr));
|
||||
autoip->tried_llipaddr++;
|
||||
autoip->state = AUTOIP_STATE_PROBING;
|
||||
autoip->sent_num = 0;
|
||||
|
||||
/* time to wait to first probe, this is randomly
|
||||
* choosen out of 0 to PROBE_WAIT seconds.
|
||||
* compliant to RFC 3927 Section 2.2.1
|
||||
*/
|
||||
autoip->ttw = (u16_t)(LWIP_AUTOIP_RAND(netif) % (PROBE_WAIT * AUTOIP_TICKS_PER_SECOND));
|
||||
|
||||
/*
|
||||
* if we tried more then MAX_CONFLICTS we must limit our rate for
|
||||
* accquiring and probing address
|
||||
* compliant to RFC 3927 Section 2.2.1
|
||||
*/
|
||||
|
||||
if(autoip->tried_llipaddr > MAX_CONFLICTS) {
|
||||
autoip->ttw = RATE_LIMIT_INTERVAL * AUTOIP_TICKS_PER_SECOND;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop AutoIP client
|
||||
*
|
||||
* @param netif network interface on which stop the AutoIP client
|
||||
*/
|
||||
err_t
|
||||
autoip_stop(struct netif *netif)
|
||||
{
|
||||
netif->autoip->state = AUTOIP_STATE_OFF;
|
||||
netif_set_down(netif);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds
|
||||
*/
|
||||
void
|
||||
autoip_tmr()
|
||||
{
|
||||
struct netif *netif = netif_list;
|
||||
/* loop through netif's */
|
||||
while (netif != NULL) {
|
||||
/* only act on AutoIP configured interfaces */
|
||||
if (netif->autoip != NULL) {
|
||||
if(netif->autoip->lastconflict > 0) {
|
||||
netif->autoip->lastconflict--;
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE,
|
||||
("autoip_tmr() AutoIP-State: %"U16_F", ttw=%"U16_F"\n",
|
||||
(u16_t)(netif->autoip->state), netif->autoip->ttw));
|
||||
|
||||
switch(netif->autoip->state) {
|
||||
case AUTOIP_STATE_PROBING:
|
||||
if(netif->autoip->ttw > 0) {
|
||||
netif->autoip->ttw--;
|
||||
} else {
|
||||
if(netif->autoip->sent_num == PROBE_NUM) {
|
||||
netif->autoip->state = AUTOIP_STATE_ANNOUNCING;
|
||||
netif->autoip->sent_num = 0;
|
||||
netif->autoip->ttw = ANNOUNCE_WAIT * AUTOIP_TICKS_PER_SECOND;
|
||||
} else {
|
||||
etharp_request(netif, &(netif->autoip->llipaddr));
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | 3,
|
||||
("autoip_tmr() PROBING Sent Probe\n"));
|
||||
netif->autoip->sent_num++;
|
||||
/* calculate time to wait to next probe */
|
||||
netif->autoip->ttw = (u16_t)((LWIP_AUTOIP_RAND(netif) %
|
||||
((PROBE_MAX - PROBE_MIN) * AUTOIP_TICKS_PER_SECOND) ) +
|
||||
PROBE_MIN * AUTOIP_TICKS_PER_SECOND);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUTOIP_STATE_ANNOUNCING:
|
||||
if(netif->autoip->ttw > 0) {
|
||||
netif->autoip->ttw--;
|
||||
} else {
|
||||
if(netif->autoip->sent_num == 0) {
|
||||
/* We are here the first time, so we waited ANNOUNCE_WAIT seconds
|
||||
* Now we can bind to an IP address and use it
|
||||
*/
|
||||
autoip_bind(netif);
|
||||
}
|
||||
|
||||
if(netif->autoip->sent_num == ANNOUNCE_NUM) {
|
||||
netif->autoip->state = AUTOIP_STATE_BOUND;
|
||||
netif->autoip->sent_num = 0;
|
||||
netif->autoip->ttw = 0;
|
||||
} else {
|
||||
autoip_arp_announce(netif);
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | 3,
|
||||
("autoip_tmr() ANNOUNCING Sent Announce\n"));
|
||||
netif->autoip->sent_num++;
|
||||
netif->autoip->ttw = ANNOUNCE_INTERVAL * AUTOIP_TICKS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* proceed to next network interface */
|
||||
netif = netif->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles every incoming ARP Packet, called by etharp_arp_input.
|
||||
*
|
||||
* @param netif network interface to use for autoip processing
|
||||
* @param hdr Incoming ARP packet
|
||||
*/
|
||||
void
|
||||
autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr)
|
||||
{
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | 3, ("autoip_arp_reply()\n"));
|
||||
if ((netif->autoip != NULL) && (netif->autoip->state != AUTOIP_STATE_OFF)) {
|
||||
/* when ip.src == llipaddr && hw.src != netif->hwaddr
|
||||
*
|
||||
* when probing ip.dst == llipaddr && hw.src != netif->hwaddr
|
||||
* we have a conflict and must solve it
|
||||
*/
|
||||
struct ip_addr sipaddr, dipaddr;
|
||||
struct eth_addr netifaddr;
|
||||
netifaddr.addr[0] = netif->hwaddr[0];
|
||||
netifaddr.addr[1] = netif->hwaddr[1];
|
||||
netifaddr.addr[2] = netif->hwaddr[2];
|
||||
netifaddr.addr[3] = netif->hwaddr[3];
|
||||
netifaddr.addr[4] = netif->hwaddr[4];
|
||||
netifaddr.addr[5] = netif->hwaddr[5];
|
||||
|
||||
/* Copy struct ip_addr2 to aligned ip_addr, to support compilers without
|
||||
* structure packing (not using structure copy which breaks strict-aliasing rules).
|
||||
*/
|
||||
SMEMCPY(&sipaddr, &hdr->sipaddr, sizeof(sipaddr));
|
||||
SMEMCPY(&dipaddr, &hdr->dipaddr, sizeof(dipaddr));
|
||||
|
||||
if ((netif->autoip->state == AUTOIP_STATE_PROBING) ||
|
||||
((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) &&
|
||||
(netif->autoip->sent_num == 0))) {
|
||||
/* RFC 3927 Section 2.2.1:
|
||||
* from beginning to after ANNOUNCE_WAIT
|
||||
* seconds we have a conflict if
|
||||
* ip.src == llipaddr OR
|
||||
* ip.dst == llipaddr && hw.src != own hwaddr
|
||||
*/
|
||||
if ((ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr)) ||
|
||||
(ip_addr_cmp(&dipaddr, &netif->autoip->llipaddr) &&
|
||||
!eth_addr_cmp(&netifaddr, &hdr->shwaddr))) {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
|
||||
("autoip_arp_reply(): Probe Conflict detected\n"));
|
||||
autoip_start(netif);
|
||||
}
|
||||
} else {
|
||||
/* RFC 3927 Section 2.5:
|
||||
* in any state we have a conflict if
|
||||
* ip.src == llipaddr && hw.src != own hwaddr
|
||||
*/
|
||||
if (ip_addr_cmp(&sipaddr, &netif->autoip->llipaddr) &&
|
||||
!eth_addr_cmp(&netifaddr, &hdr->shwaddr)) {
|
||||
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE | 1,
|
||||
("autoip_arp_reply(): Conflicting ARP-Packet detected\n"));
|
||||
autoip_handle_arp_conflict(netif);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LWIP_AUTOIP */
|
||||
@@ -1,8 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
* ICMP - Internet Control Message Protocol
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@@ -11,21 +17,21 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
@@ -33,167 +39,293 @@
|
||||
/* Some ICMP messages should be passed to the transport protocols. This
|
||||
is not implemented. */
|
||||
|
||||
#include "lwip/debug.h"
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/inet_chksum.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/def.h"
|
||||
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/snmp.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#include <string.h>
|
||||
|
||||
/** Small optimization: set to 0 if incoming PBUF_POOL pbuf always can be
|
||||
* used to modify and send a response packet (and to 1 if this is not the case,
|
||||
* e.g. when link header is stripped of when receiving) */
|
||||
#ifndef LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
||||
#define LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN 1
|
||||
#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */
|
||||
|
||||
/* The amount of data from the original packet to return in a dest-unreachable */
|
||||
#define ICMP_DEST_UNREACH_DATASIZE 8
|
||||
|
||||
static void icmp_send_response(struct pbuf *p, u8_t type, u8_t code);
|
||||
|
||||
/**
|
||||
* Processes ICMP input packets, called from ip_input().
|
||||
*
|
||||
* Currently only processes icmp echo requests and sends
|
||||
* out the echo response.
|
||||
*
|
||||
* @param p the icmp echo request packet, p->payload pointing to the ip header
|
||||
* @param inp the netif on which this packet was received
|
||||
*/
|
||||
void
|
||||
icmp_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
unsigned char type;
|
||||
u8_t type;
|
||||
#ifdef LWIP_DEBUG
|
||||
u8_t code;
|
||||
#endif /* LWIP_DEBUG */
|
||||
struct icmp_echo_hdr *iecho;
|
||||
struct ip_hdr *iphdr;
|
||||
struct ip_addr tmpaddr;
|
||||
u16_t hlen;
|
||||
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.recv;
|
||||
#endif /* ICMP_STATS */
|
||||
s16_t hlen;
|
||||
|
||||
ICMP_STATS_INC(icmp.recv);
|
||||
snmp_inc_icmpinmsgs();
|
||||
|
||||
|
||||
|
||||
iphdr = p->payload;
|
||||
hlen = IPH_HL(iphdr) * 4/sizeof(u8_t);
|
||||
pbuf_header(p, -hlen);
|
||||
hlen = IPH_HL(iphdr) * 4;
|
||||
if (pbuf_header(p, -hlen) || (p->tot_len < sizeof(u16_t)*2)) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len));
|
||||
goto lenerr;
|
||||
}
|
||||
|
||||
type = *((u8_t *)p->payload);
|
||||
|
||||
switch(type) {
|
||||
#ifdef LWIP_DEBUG
|
||||
code = *(((u8_t *)p->payload)+1);
|
||||
#endif /* LWIP_DEBUG */
|
||||
switch (type) {
|
||||
case ICMP_ECHO:
|
||||
if(ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||
|
||||
ip_addr_ismulticast(&iphdr->dest)) {
|
||||
DEBUGF(ICMP_DEBUG, ("Smurf.\n"));
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.err;
|
||||
#endif /* ICMP_STATS */
|
||||
#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING
|
||||
{
|
||||
int accepted = 1;
|
||||
#if !LWIP_MULTICAST_PING
|
||||
/* multicast destination address? */
|
||||
if (ip_addr_ismulticast(&iphdr->dest)) {
|
||||
accepted = 0;
|
||||
}
|
||||
#endif /* LWIP_MULTICAST_PING */
|
||||
#if !LWIP_BROADCAST_PING
|
||||
/* broadcast destination address? */
|
||||
if (ip_addr_isbroadcast(&iphdr->dest, inp)) {
|
||||
accepted = 0;
|
||||
}
|
||||
#endif /* LWIP_BROADCAST_PING */
|
||||
/* broadcast or multicast destination address not acceptd? */
|
||||
if (!accepted) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n"));
|
||||
ICMP_STATS_INC(icmp.err);
|
||||
pbuf_free(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif /* !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
|
||||
if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
||||
goto lenerr;
|
||||
}
|
||||
if (inet_chksum_pbuf(p) != 0) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
|
||||
pbuf_free(p);
|
||||
ICMP_STATS_INC(icmp.chkerr);
|
||||
snmp_inc_icmpinerrors();
|
||||
return;
|
||||
}
|
||||
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
|
||||
DEBUGF(DEMO_DEBUG, ("Pong!\n"));
|
||||
if(p->tot_len < sizeof(struct icmp_echo_hdr)) {
|
||||
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
|
||||
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
||||
if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) {
|
||||
/* p is not big enough to contain link headers
|
||||
* allocate a new one and copy p into it
|
||||
*/
|
||||
struct pbuf *r;
|
||||
/* switch p->payload to ip header */
|
||||
if (pbuf_header(p, hlen)) {
|
||||
LWIP_ASSERT("icmp_input: moving p->payload to ip header failed\n", 0);
|
||||
goto memerr;
|
||||
}
|
||||
/* allocate new packet buffer with space for link headers */
|
||||
r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
|
||||
if (r == NULL) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: allocating new pbuf failed\n"));
|
||||
goto memerr;
|
||||
}
|
||||
LWIP_ASSERT("check that first pbuf can hold struct the ICMP header",
|
||||
(r->len >= hlen + sizeof(struct icmp_echo_hdr)));
|
||||
/* copy the whole packet including ip header */
|
||||
if (pbuf_copy(r, p) != ERR_OK) {
|
||||
LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0);
|
||||
goto memerr;
|
||||
}
|
||||
iphdr = r->payload;
|
||||
/* switch r->payload back to icmp header */
|
||||
if (pbuf_header(r, -hlen)) {
|
||||
LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0);
|
||||
goto memerr;
|
||||
}
|
||||
/* free the original p */
|
||||
pbuf_free(p);
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.lenerr;
|
||||
#endif /* ICMP_STATS */
|
||||
|
||||
return;
|
||||
}
|
||||
iecho = p->payload;
|
||||
if(inet_chksum_pbuf(p) != 0) {
|
||||
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
|
||||
pbuf_free(p);
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.chkerr;
|
||||
#endif /* ICMP_STATS */
|
||||
return;
|
||||
/* we now have an identical copy of p that has room for link headers */
|
||||
p = r;
|
||||
} else {
|
||||
/* restore p->payload to point to icmp header */
|
||||
if (pbuf_header(p, -(s16_t)(PBUF_IP_HLEN + PBUF_LINK_HLEN))) {
|
||||
LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0);
|
||||
goto memerr;
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */
|
||||
/* At this point, all checks are OK. */
|
||||
/* We generate an answer by switching the dest and src ip addresses,
|
||||
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
||||
iecho = p->payload;
|
||||
tmpaddr.addr = iphdr->src.addr;
|
||||
iphdr->src.addr = iphdr->dest.addr;
|
||||
iphdr->dest.addr = tmpaddr.addr;
|
||||
ICMPH_TYPE_SET(iecho, ICMP_ER);
|
||||
/* adjust the checksum */
|
||||
if(iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
|
||||
if (iecho->chksum >= htons(0xffff - (ICMP_ECHO << 8))) {
|
||||
iecho->chksum += htons(ICMP_ECHO << 8) + 1;
|
||||
} else {
|
||||
iecho->chksum += htons(ICMP_ECHO << 8);
|
||||
}
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.xmit;
|
||||
#endif /* ICMP_STATS */
|
||||
|
||||
pbuf_header(p, hlen);
|
||||
ip_output_if(p, &(iphdr->src), IP_HDRINCL,
|
||||
IPH_TTL(iphdr), IP_PROTO_ICMP, inp);
|
||||
break;
|
||||
/* Set the correct TTL and recalculate the header checksum. */
|
||||
IPH_TTL_SET(iphdr, ICMP_TTL);
|
||||
IPH_CHKSUM_SET(iphdr, 0);
|
||||
#if CHECKSUM_GEN_IP
|
||||
IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN));
|
||||
#endif /* CHECKSUM_GEN_IP */
|
||||
|
||||
ICMP_STATS_INC(icmp.xmit);
|
||||
/* increase number of messages attempted to send */
|
||||
snmp_inc_icmpoutmsgs();
|
||||
/* increase number of echo replies attempted to send */
|
||||
snmp_inc_icmpoutechoreps();
|
||||
|
||||
if(pbuf_header(p, hlen)) {
|
||||
LWIP_ASSERT("Can't move over header in packet", 0);
|
||||
} else {
|
||||
err_t ret;
|
||||
ret = ip_output_if(p, &(iphdr->src), IP_HDRINCL,
|
||||
ICMP_TTL, 0, IP_PROTO_ICMP, inp);
|
||||
if (ret != ERR_OK) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type not supported.\n"));
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.proterr;
|
||||
++stats.icmp.drop;
|
||||
#endif /* ICMP_STATS */
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n",
|
||||
(s16_t)type, (s16_t)code));
|
||||
ICMP_STATS_INC(icmp.proterr);
|
||||
ICMP_STATS_INC(icmp.drop);
|
||||
}
|
||||
pbuf_free(p);
|
||||
return;
|
||||
lenerr:
|
||||
pbuf_free(p);
|
||||
ICMP_STATS_INC(icmp.lenerr);
|
||||
snmp_inc_icmpinerrors();
|
||||
return;
|
||||
#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN
|
||||
memerr:
|
||||
pbuf_free(p);
|
||||
ICMP_STATS_INC(icmp.err);
|
||||
snmp_inc_icmpinerrors();
|
||||
return;
|
||||
#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Send an icmp 'destination unreachable' packet, called from ip_input() if
|
||||
* the transport layer protocol is unknown and from udp_input() if the local
|
||||
* port is not bound.
|
||||
*
|
||||
* @param p the input packet for which the 'unreachable' should be sent,
|
||||
* p->payload pointing to the IP header
|
||||
* @param t type of the 'unreachable' packet
|
||||
*/
|
||||
void
|
||||
icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
||||
{
|
||||
struct pbuf *q;
|
||||
struct ip_hdr *iphdr;
|
||||
struct icmp_dur_hdr *idur;
|
||||
|
||||
q = pbuf_alloc(PBUF_TRANSPORT, 8 + IP_HLEN + 8, PBUF_RAM);
|
||||
/* ICMP header + IP header + 8 bytes of data */
|
||||
|
||||
iphdr = p->payload;
|
||||
|
||||
idur = q->payload;
|
||||
ICMPH_TYPE_SET(idur, ICMP_DUR);
|
||||
ICMPH_CODE_SET(idur, t);
|
||||
|
||||
bcopy(p->payload, (char *)q->payload + 8, IP_HLEN + 8);
|
||||
|
||||
/* calculate checksum */
|
||||
idur->chksum = 0;
|
||||
idur->chksum = inet_chksum(idur, q->len);
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.xmit;
|
||||
#endif /* ICMP_STATS */
|
||||
|
||||
ip_output(q, NULL, &(iphdr->src),
|
||||
ICMP_TTL, IP_PROTO_ICMP);
|
||||
pbuf_free(q);
|
||||
icmp_send_response(p, ICMP_DUR, t);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if IP_FORWARD
|
||||
|
||||
#if IP_FORWARD || IP_REASSEMBLY
|
||||
/**
|
||||
* Send a 'time exceeded' packet, called from ip_forward() if TTL is 0.
|
||||
*
|
||||
* @param p the input packet for which the 'time exceeded' should be sent,
|
||||
* p->payload pointing to the IP header
|
||||
* @param t type of the 'time exceeded' packet
|
||||
*/
|
||||
void
|
||||
icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
||||
{
|
||||
icmp_send_response(p, ICMP_TE, t);
|
||||
}
|
||||
|
||||
#endif /* IP_FORWARD || IP_REASSEMBLY */
|
||||
|
||||
/**
|
||||
* Send an icmp packet in response to an incoming packet.
|
||||
*
|
||||
* @param p the input packet for which the 'unreachable' should be sent,
|
||||
* p->payload pointing to the IP header
|
||||
* @param type Type of the ICMP header
|
||||
* @param code Code of the ICMP header
|
||||
*/
|
||||
static void
|
||||
icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
||||
{
|
||||
struct pbuf *q;
|
||||
struct ip_hdr *iphdr;
|
||||
struct icmp_te_hdr *tehdr;
|
||||
/* we can use the echo header here */
|
||||
struct icmp_echo_hdr *icmphdr;
|
||||
|
||||
q = pbuf_alloc(PBUF_TRANSPORT, 8 + IP_HLEN + 8, PBUF_RAM);
|
||||
/* ICMP header + IP header + 8 bytes of data */
|
||||
q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE,
|
||||
PBUF_RAM);
|
||||
if (q == NULL) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n"));
|
||||
return;
|
||||
}
|
||||
LWIP_ASSERT("check that first pbuf can hold icmp message",
|
||||
(q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE)));
|
||||
|
||||
iphdr = p->payload;
|
||||
#if ICMP_DEBUG
|
||||
DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
|
||||
ip_addr_debug_print(&(iphdr->src));
|
||||
DEBUGF(ICMP_DEBUG, (" to "));
|
||||
ip_addr_debug_print(&(iphdr->dest));
|
||||
DEBUGF(ICMP_DEBUG, ("\n"));
|
||||
#endif /* ICMP_DEBNUG */
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, (" to "));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
|
||||
|
||||
tehdr = q->payload;
|
||||
ICMPH_TYPE_SET(tehdr, ICMP_TE);
|
||||
ICMPH_CODE_SET(tehdr, t);
|
||||
icmphdr = q->payload;
|
||||
icmphdr->type = type;
|
||||
icmphdr->code = code;
|
||||
icmphdr->id = 0;
|
||||
icmphdr->seqno = 0;
|
||||
|
||||
/* copy fields from original packet */
|
||||
bcopy((char *)p->payload, (char *)q->payload + 8, IP_HLEN + 8);
|
||||
|
||||
SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload,
|
||||
IP_HLEN + ICMP_DEST_UNREACH_DATASIZE);
|
||||
|
||||
/* calculate checksum */
|
||||
tehdr->chksum = 0;
|
||||
tehdr->chksum = inet_chksum(tehdr, q->len);
|
||||
#ifdef ICMP_STATS
|
||||
++stats.icmp.xmit;
|
||||
#endif /* ICMP_STATS */
|
||||
ip_output(q, NULL, &(iphdr->src),
|
||||
ICMP_TTL, IP_PROTO_ICMP);
|
||||
icmphdr->chksum = 0;
|
||||
icmphdr->chksum = inet_chksum(icmphdr, q->len);
|
||||
ICMP_STATS_INC(icmp.xmit);
|
||||
/* increase number of messages attempted to send */
|
||||
snmp_inc_icmpoutmsgs();
|
||||
/* increase number of destination unreachable messages attempted to send */
|
||||
snmp_inc_icmpouttimeexcds();
|
||||
ip_output(q, NULL, &(iphdr->src), ICMP_TTL, 0, IP_PROTO_ICMP);
|
||||
pbuf_free(q);
|
||||
}
|
||||
|
||||
#endif /* IP_FORWARDING > 0 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* LWIP_ICMP */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user