简单介绍
lwIP is a small independent implementation of the TCP/IP protocol suite that has been initially developed by Adam Dunkels and is now continued here. The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40kilobytes of code ROM.
LwIP是瑞典计算机科学院Adam Dunkels开发的一个独立的小型开源TCP/IP协议栈,项目目前仍然在维护中。它实现的重点是在保持TCP协议主要功能的基础上减少对RAM的占用,这使LwIP协议栈适合在低端的嵌入式系统中使用。
LwIP的主要特性:
支持多网络接口下的IP转发;
支持ICMP协议;
包括实验性扩展的UDP(用户数据报协议);
包括阻塞控制、RTT 估算、快速恢复和快速转发的TCP(传输控制协议);
提供专门的内部回调接口(Raw API),用于提高应用程序性能;
可选择的Berkeley接口API (在多线程情况下使用) ;
支持ppp;
支持IP fragment的;
支持DHCP协议,动态分配ip地址;
参考图书
重要网址
LwIP源代码文件目录 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 mancode@manos:~/objs/lwip-STABLE-2_2_0_RELEASE$ mancode@manos:~/objs/lwip-STABLE-2_2_0_RELEASE$ tree . . ├── BUILDING ├── CHANGELOG ├── CMakeLists.txt ├── codespell_changed_files.sh ├── codespell_check.sh ├── contrib │ ├── addons │ │ ├── dhcp_extra_opts │ │ │ ├── dhcp_extra_opts.c │ │ │ ├── dhcp_extra_opts.h │ │ │ └── README │ │ ├── ipv6_static_routing │ │ │ ├── ip6_route_table.c │ │ │ ├── ip6_route_table.h │ │ │ └── README │ │ ├── netconn │ │ │ └── external_resolve │ │ │ ├── dnssd.c │ │ │ └── dnssd.h │ │ ├── tcp_isn │ │ │ ├── tcp_isn.c │ │ │ └── tcp_isn.h │ │ └── tcp_md5 │ │ ├── README │ │ ├── tcp_md5.c │ │ └── tcp_md5.h │ ├── apps │ │ ├── chargen │ │ │ ├── chargen.c │ │ │ ├── chargen.h │ │ │ └── README │ │ ├── httpserver │ │ │ ├── httpserver-netconn.c │ │ │ ├── httpserver-netconn.h │ │ │ └── README │ │ ├── LwipMibCompiler │ │ │ ├── CCodeGeneration │ │ │ │ ├── CCodeGeneration.csproj │ │ │ │ ├── CFile.cs │ │ │ │ ├── CGenerator.cs │ │ │ │ ├── CodeContainerBase.cs │ │ │ │ ├── Code.cs │ │ │ │ ├── CodeElement.cs │ │ │ │ ├── Comment.cs │ │ │ │ ├── EmptyLine.cs │ │ │ │ ├── Function.cs │ │ │ │ ├── FunctionDeclaration.cs │ │ │ │ ├── IfThenElse.cs │ │ │ │ ├── PlainText.cs │ │ │ │ ├── PP_If.cs │ │ │ │ ├── PP_Ifdef.cs │ │ │ │ ├── PP_Include.cs │ │ │ │ ├── PP_Macro.cs │ │ │ │ ├── Properties │ │ │ │ │ └── AssemblyInfo.cs │ │ │ │ ├── Switch.cs │ │ │ │ ├── VariableDeclaration.cs │ │ │ │ ├── VariablePrototype.cs │ │ │ │ └── VariableType.cs │ │ │ ├── example │ │ │ │ ├── compile_udp_mib.cmd │ │ │ │ └── compile_udp_mib.sh │ │ │ ├── LwipMibCompiler │ │ │ │ ├── app.config │ │ │ │ ├── LwipMibCompiler.csproj │ │ │ │ ├── Program.cs │ │ │ │ └── Properties │ │ │ │ └── AssemblyInfo.cs │ │ │ ├── LwipMibCompiler.sln │ │ │ ├── LwipSnmpCodeGeneration │ │ │ │ ├── IRestriction.cs │ │ │ │ ├── LwipSnmpCodeGeneration.csproj │ │ │ │ ├── LwipSnmp.cs │ │ │ │ ├── MibCFile.cs │ │ │ │ ├── MibHeaderFile.cs │ │ │ │ ├── Properties │ │ │ │ │ └── AssemblyInfo.cs │ │ │ │ ├── SnmpMib.cs │ │ │ │ ├── SnmpNode.cs │ │ │ │ ├── SnmpScalarAggregationNode.cs │ │ │ │ ├── SnmpScalarArrayNode.cs │ │ │ │ ├── SnmpScalarNodeBits.cs │ │ │ │ ├── SnmpScalarNodeCounter64.cs │ │ │ │ ├── SnmpScalarNode.cs │ │ │ │ ├── SnmpScalarNodeInt.cs │ │ │ │ ├── SnmpScalarNodeObjectIdentifier.cs │ │ │ │ ├── SnmpScalarNodeOctetString.cs │ │ │ │ ├── SnmpScalarNodeTruthValue.cs │ │ │ │ ├── SnmpScalarNodeUint.cs │ │ │ │ ├── SnmpTableNode.cs │ │ │ │ └── SnmpTreeNode.cs │ │ │ ├── Mibs │ │ │ │ ├── IANA │ │ │ │ │ ├── IANAifType-MIB │ │ │ │ │ ├── IANA-ITU-ALARM-TC-MIB │ │ │ │ │ ├── IANA-LANGUAGE-MIB │ │ │ │ │ ├── IANA-MALLOC-MIB │ │ │ │ │ ├── IANA-MAU-MIB │ │ │ │ │ ├── IANA-PRINTER-MIB │ │ │ │ │ ├── IANA-RTPROTO-MIB │ │ │ │ │ └── IANATn3270eTC-MIB │ │ │ │ ├── IANA-ADDRESS-FAMILY-NUMBERS-MIB │ │ │ │ ├── IANA-CHARSET-MIB │ │ │ │ ├── IF-MIB │ │ │ │ ├── INET-ADDRESS-MIB │ │ │ │ ├── IP-MIB │ │ │ │ ├── RFC1065-SMI │ │ │ │ ├── RFC1155-SMI │ │ │ │ ├── RFC1158-MIB │ │ │ │ ├── RFC-1212 │ │ │ │ ├── RFC1213-MIB │ │ │ │ ├── RFC-1215 │ │ │ │ ├── SNMPv2-CONF │ │ │ │ ├── SNMPv2-MIB │ │ │ │ ├── SNMPv2-SMI │ │ │ │ ├── SNMPv2-TC │ │ │ │ ├── SNMPv2-TM │ │ │ │ ├── TCP-MIB │ │ │ │ └── UDP-MIB │ │ │ ├── MibViewer │ │ │ │ ├── app.config │ │ │ │ ├── FormMain.cs │ │ │ │ ├── FormMain.Designer.cs │ │ │ │ ├── FormMain.resx │ │ │ │ ├── MibViewer.csproj │ │ │ │ ├── Program.cs │ │ │ │ └── Properties │ │ │ │ ├── AssemblyInfo.cs │ │ │ │ ├── Resources.Designer.cs │ │ │ │ ├── Resources.resx │ │ │ │ ├── Settings.Designer.cs │ │ │ │ └── Settings.settings │ │ │ └── SharpSnmpLib │ │ │ ├── license.txt │ │ │ ├── Mib │ │ │ │ ├── DisplayHint.cs │ │ │ │ ├── Elements │ │ │ │ │ ├── Entities │ │ │ │ │ │ ├── AgentCapabilities.cs │ │ │ │ │ │ ├── EntityBase.cs │ │ │ │ │ │ ├── IEntity.cs │ │ │ │ │ │ ├── ModuleCompliance.cs │ │ │ │ │ │ ├── ModuleIdentity.cs │ │ │ │ │ │ ├── NotificationGroup.cs │ │ │ │ │ │ ├── NotificationType.cs │ │ │ │ │ │ ├── ObjectGroup.cs │ │ │ │ │ │ ├── ObjectIdentity.cs │ │ │ │ │ │ ├── ObjectType.cs │ │ │ │ │ │ └── OidValueAssignment.cs │ │ │ │ │ ├── Exports.cs │ │ │ │ │ ├── IDeclaration.cs │ │ │ │ │ ├── IElement.cs │ │ │ │ │ ├── Imports.cs │ │ │ │ │ ├── ImportsFrom.cs │ │ │ │ │ ├── ITypeReferrer.cs │ │ │ │ │ ├── TrapType.cs │ │ │ │ │ └── Types │ │ │ │ │ ├── BaseType.cs │ │ │ │ │ ├── BitsType.cs │ │ │ │ │ ├── Choice.cs │ │ │ │ │ ├── IntegerType.cs │ │ │ │ │ ├── IpAddressType.cs │ │ │ │ │ ├── ITypeAssignment.cs │ │ │ │ │ ├── Macro.cs │ │ │ │ │ ├── ObjectIdentifierType.cs │ │ │ │ │ ├── OctetStringType.cs │ │ │ │ │ ├── OpaqueType.cs │ │ │ │ │ ├── Sequence.cs │ │ │ │ │ ├── SequenceOf.cs │ │ │ │ │ ├── TextualConvention.cs │ │ │ │ │ ├── TypeAssignment.cs │ │ │ │ │ └── UnsignedType.cs │ │ │ │ ├── IModule.cs │ │ │ │ ├── ISymbolEnumerator.cs │ │ │ │ ├── Lexer.cs │ │ │ │ ├── MaxAccess.cs │ │ │ │ ├── MibDocument.cs │ │ │ │ ├── MibException.cs │ │ │ │ ├── MibModule.cs │ │ │ │ ├── MibResolver.cs │ │ │ │ ├── MibTree.cs │ │ │ │ ├── MibTreeNode.cs │ │ │ │ ├── MibTypesResolver.cs │ │ │ │ ├── ObjectIdentifier.cs │ │ │ │ ├── Status.cs │ │ │ │ ├── Symbol.cs │ │ │ │ ├── SymbolList.cs │ │ │ │ ├── ValueMap.cs │ │ │ │ └── ValueRange.cs │ │ │ ├── Properties │ │ │ │ ├── AssemblyInfo.cs │ │ │ │ ├── Resources.Designer.cs │ │ │ │ └── Resources.resx │ │ │ ├── readme.txt │ │ │ ├── SharpSnmpLib.Mib.csproj │ │ │ └── sharpsnmplib.snk │ │ ├── netio │ │ │ ├── netio.c │ │ │ └── netio.h │ │ ├── ping │ │ │ ├── ping.c │ │ │ └── ping.h │ │ ├── rtp │ │ │ ├── rtp.c │ │ │ ├── rtpdata.h │ │ │ └── rtp.h │ │ ├── shell │ │ │ ├── shell.c │ │ │ └── shell.h │ │ ├── socket_examples │ │ │ ├── socket_examples.c │ │ │ └── socket_examples.h │ │ ├── tcpecho │ │ │ ├── tcpecho.c │ │ │ └── tcpecho.h │ │ ├── tcpecho_raw │ │ │ ├── tcpecho_raw.c │ │ │ └── tcpecho_raw.h │ │ ├── udpecho │ │ │ ├── udpecho.c │ │ │ └── udpecho.h │ │ └── udpecho_raw │ │ ├── udpecho_raw.c │ │ └── udpecho_raw.h │ ├── Coverity │ │ └── coverity.c │ ├── examples │ │ ├── ethernetif │ │ │ └── ethernetif.c │ │ ├── example_app │ │ │ ├── default_netif.h │ │ │ ├── lwipcfg.h.ci │ │ │ ├── lwipcfg.h.example │ │ │ ├── lwipopts.h │ │ │ ├── lwippools.h │ │ │ ├── ppp_settings.h │ │ │ ├── test.c │ │ │ └── test_configs │ │ │ ├── opt_default.h │ │ │ ├── opt_dualstack.h │ │ │ ├── opt_ipv4only.h │ │ │ ├── opt_ipv6only.h │ │ │ ├── opt_none.h │ │ │ ├── opt_nosys_dual.h │ │ │ ├── opt_nosys_ipv4.h │ │ │ ├── opt_nosys_ipv6.h │ │ │ ├── opt_no_tcp_dualstack.h │ │ │ ├── opt_no_tcp_ipv4only.h │ │ │ ├── opt_no_tcp_ipv6only.h │ │ │ ├── opt_no_udp_dualstack.h │ │ │ ├── opt_no_udp_ipv4only.h │ │ │ └── opt_no_udp_ipv6only.h │ │ ├── httpd │ │ │ ├── cgi_example │ │ │ │ ├── cgi_example.c │ │ │ │ └── cgi_example.h │ │ │ ├── examples_fs │ │ │ │ ├── 404.html │ │ │ │ ├── img │ │ │ │ │ └── sics.gif │ │ │ │ ├── index.html │ │ │ │ ├── loginfail.html │ │ │ │ ├── login.html │ │ │ │ ├── session.html │ │ │ │ └── ssi.shtml │ │ │ ├── examples_fsdata.c │ │ │ ├── fs_example │ │ │ │ ├── fs_example.c │ │ │ │ └── fs_example.h │ │ │ ├── genfiles_example │ │ │ │ ├── genfiles_example.c │ │ │ │ └── genfiles_example.h │ │ │ ├── https_example │ │ │ │ ├── https_example.c │ │ │ │ └── https_example.h │ │ │ ├── post_example │ │ │ │ └── post_example.c │ │ │ └── ssi_example │ │ │ ├── ssi_example.c │ │ │ └── ssi_example.h │ │ ├── lwiperf │ │ │ ├── lwiperf_example.c │ │ │ └── lwiperf_example.h │ │ ├── mdns │ │ │ ├── mdns_example.c │ │ │ └── mdns_example.h │ │ ├── mqtt │ │ │ ├── mqtt_example.c │ │ │ └── mqtt_example.h │ │ ├── ppp │ │ │ ├── pppos_example.c │ │ │ └── pppos_example.h │ │ ├── snmp │ │ │ ├── snmp_example.c │ │ │ ├── snmp_example.h │ │ │ ├── snmp_private_mib │ │ │ │ ├── lwip_prvmib.c │ │ │ │ └── private_mib.h │ │ │ └── snmp_v3 │ │ │ ├── snmpv3_dummy.c │ │ │ └── snmpv3_dummy.h │ │ ├── sntp │ │ │ ├── sntp_example.c │ │ │ └── sntp_example.h │ │ └── tftp │ │ ├── tftp_example.c │ │ └── tftp_example.h │ ├── Filelists.cmake │ ├── Filelists.mk │ └── ports │ ├── CMakeCommon.cmake │ ├── Common.allports.mk │ ├── freertos │ │ ├── include │ │ │ └── arch │ │ │ └── sys_arch.h │ │ └── sys_arch.c │ ├── unix │ │ ├── check │ │ │ ├── CMakeLists.txt │ │ │ ├── config.h │ │ │ ├── Makefile │ │ │ └── README │ │ ├── Common.mk │ │ ├── example_app │ │ │ ├── CMakeLists.txt │ │ │ ├── default_netif.c │ │ │ ├── iteropts.sh │ │ │ └── Makefile │ │ ├── Filelists.cmake │ │ ├── lib │ │ │ ├── CMakeLists.txt │ │ │ ├── lwipopts.h │ │ │ └── README │ │ ├── port │ │ │ ├── include │ │ │ │ ├── arch │ │ │ │ │ ├── cc.h │ │ │ │ │ ├── perf.h │ │ │ │ │ └── sys_arch.h │ │ │ │ └── netif │ │ │ │ ├── fifo.h │ │ │ │ ├── list.h │ │ │ │ ├── pcapif.h │ │ │ │ ├── sio.h │ │ │ │ ├── tapif.h │ │ │ │ └── vdeif.h │ │ │ ├── netif │ │ │ │ ├── fifo.c │ │ │ │ ├── list.c │ │ │ │ ├── pcapif.c │ │ │ │ ├── sio.c │ │ │ │ ├── tapif.c │ │ │ │ └── vdeif.c │ │ │ ├── perf.c │ │ │ └── sys_arch.c │ │ ├── posixlib │ │ │ ├── CMakeLists.txt │ │ │ ├── include │ │ │ │ └── posix │ │ │ │ ├── inet.h │ │ │ │ └── sockets.h │ │ │ ├── lwipopts.h │ │ │ └── Uninstall.cmake │ │ ├── README │ │ └── setup-tapif │ └── win32 │ ├── check │ │ ├── check_stdint.h │ │ ├── config.h │ │ ├── stdbool.h │ │ ├── sys │ │ │ └── time.h │ │ ├── time.c │ │ └── unistd.h │ ├── Common.mk │ ├── example_app │ │ ├── CMakeLists.txt │ │ ├── default_netif.c │ │ └── Makefile │ ├── Filelists.cmake │ ├── include │ │ └── arch │ │ ├── bpstruct.h │ │ ├── cc.h │ │ ├── epstruct.h │ │ ├── perf.h │ │ └── sys_arch.h │ ├── msvc │ │ ├── build_coverity.cmd │ │ ├── libcheck.vcxproj │ │ ├── libcheck.vcxproj.filters │ │ ├── lwIP_pcapif.vcxproj │ │ ├── lwIP_pcapif.vcxproj.filters │ │ ├── lwIP_Test.sln │ │ ├── lwIP_Test.vcxproj │ │ ├── lwIP_Test.vcxproj.filters │ │ ├── lwIP_unittests.sln │ │ ├── lwip_unittests.vcxproj │ │ ├── lwip_unittests.vcxproj.filters │ │ ├── lwIP.vcxproj │ │ ├── lwIP.vcxproj.filters │ │ ├── makefsdata.vcxproj │ │ └── makefsdata.vcxproj.filters │ ├── pcapif.c │ ├── pcapif.h │ ├── pcapif_helper.c │ ├── pcapif_helper.h │ ├── readme.txt │ ├── sio.c │ └── sys_arch.c ├── COPYING ├── doc │ ├── contrib.txt │ ├── doxygen │ │ ├── generate.bat │ │ ├── generate.sh │ │ ├── lwip.Doxyfile │ │ ├── lwip.Doxyfile.cmake.in │ │ ├── main_page.h │ │ └── output │ │ └── index.html │ ├── FILES │ ├── mdns.txt │ ├── mqtt_client.txt │ ├── NO_SYS_SampleCode.c │ ├── ppp.txt │ ├── savannah.txt │ └── ZeroCopyRx.c ├── FEATURES ├── FILES ├── README ├── src │ ├── api │ │ ├── api_lib.c │ │ ├── api_msg.c │ │ ├── err.c │ │ ├── if_api.c │ │ ├── netbuf.c │ │ ├── netdb.c │ │ ├── netifapi.c │ │ ├── sockets.c │ │ └── tcpip.c │ ├── apps │ │ ├── altcp_tls │ │ │ ├── altcp_tls_mbedtls.c │ │ │ ├── altcp_tls_mbedtls_mem.c │ │ │ ├── altcp_tls_mbedtls_mem.h │ │ │ └── altcp_tls_mbedtls_structs.h │ │ ├── http │ │ │ ├── altcp_proxyconnect.c │ │ │ ├── fs │ │ │ │ ├── 404.html │ │ │ │ ├── img │ │ │ │ │ └── sics.gif │ │ │ │ └── index.html │ │ │ ├── fs.c │ │ │ ├── fsdata.c │ │ │ ├── fsdata.h │ │ │ ├── http_client.c │ │ │ ├── httpd.c │ │ │ ├── httpd_structs.h │ │ │ └── makefsdata │ │ │ ├── makefsdata │ │ │ ├── makefsdata.c │ │ │ ├── readme.txt │ │ │ └── tinydir.h │ │ ├── lwiperf │ │ │ └── lwiperf.c │ │ ├── mdns │ │ │ ├── mdns.c │ │ │ ├── mdns_domain.c │ │ │ └── mdns_out.c │ │ ├── mqtt │ │ │ └── mqtt.c │ │ ├── netbiosns │ │ │ └── netbiosns.c │ │ ├── smtp │ │ │ └── smtp.c │ │ ├── snmp │ │ │ ├── snmp_asn1.c │ │ │ ├── snmp_asn1.h │ │ │ ├── snmp_core.c │ │ │ ├── snmp_core_priv.h │ │ │ ├── snmp_mib2.c │ │ │ ├── snmp_mib2_icmp.c │ │ │ ├── snmp_mib2_interfaces.c │ │ │ ├── snmp_mib2_ip.c │ │ │ ├── snmp_mib2_snmp.c │ │ │ ├── snmp_mib2_system.c │ │ │ ├── snmp_mib2_tcp.c │ │ │ ├── snmp_mib2_udp.c │ │ │ ├── snmp_msg.c │ │ │ ├── snmp_msg.h │ │ │ ├── snmp_netconn.c │ │ │ ├── snmp_pbuf_stream.c │ │ │ ├── snmp_pbuf_stream.h │ │ │ ├── snmp_raw.c │ │ │ ├── snmp_scalar.c │ │ │ ├── snmp_snmpv2_framework.c │ │ │ ├── snmp_snmpv2_usm.c │ │ │ ├── snmp_table.c │ │ │ ├── snmp_threadsync.c │ │ │ ├── snmp_traps.c │ │ │ ├── snmpv3.c │ │ │ ├── snmpv3_mbedtls.c │ │ │ └── snmpv3_priv.h │ │ ├── sntp │ │ │ └── sntp.c │ │ └── tftp │ │ └── tftp.c │ ├── core │ │ ├── altcp_alloc.c │ │ ├── altcp.c │ │ ├── altcp_tcp.c │ │ ├── def.c │ │ ├── dns.c │ │ ├── inet_chksum.c │ │ ├── init.c │ │ ├── ip.c │ │ ├── ipv4 │ │ │ ├── acd.c │ │ │ ├── autoip.c │ │ │ ├── dhcp.c │ │ │ ├── etharp.c │ │ │ ├── icmp.c │ │ │ ├── igmp.c │ │ │ ├── ip4_addr.c │ │ │ ├── ip4.c │ │ │ └── ip4_frag.c │ │ ├── ipv6 │ │ │ ├── dhcp6.c │ │ │ ├── ethip6.c │ │ │ ├── icmp6.c │ │ │ ├── inet6.c │ │ │ ├── ip6_addr.c │ │ │ ├── ip6.c │ │ │ ├── ip6_frag.c │ │ │ ├── mld6.c │ │ │ └── nd6.c │ │ ├── mem.c │ │ ├── memp.c │ │ ├── netif.c │ │ ├── pbuf.c │ │ ├── raw.c │ │ ├── stats.c │ │ ├── sys.c │ │ ├── tcp.c │ │ ├── tcp_in.c │ │ ├── tcp_out.c │ │ ├── timeouts.c │ │ └── udp.c │ ├── Filelists.cmake │ ├── Filelists.mk │ ├── FILES │ ├── include │ │ ├── compat │ │ │ ├── posix │ │ │ │ ├── arpa │ │ │ │ │ └── inet.h │ │ │ │ ├── net │ │ │ │ │ └── if.h │ │ │ │ ├── netdb.h │ │ │ │ └── sys │ │ │ │ └── socket.h │ │ │ └── stdc │ │ │ └── errno.h │ │ ├── lwip │ │ │ ├── acd.h │ │ │ ├── altcp.h │ │ │ ├── altcp_tcp.h │ │ │ ├── altcp_tls.h │ │ │ ├── api.h │ │ │ ├── apps │ │ │ │ ├── altcp_proxyconnect.h │ │ │ │ ├── altcp_tls_mbedtls_opts.h │ │ │ │ ├── FILES │ │ │ │ ├── fs.h │ │ │ │ ├── http_client.h │ │ │ │ ├── httpd.h │ │ │ │ ├── httpd_opts.h │ │ │ │ ├── lwiperf.h │ │ │ │ ├── mdns_domain.h │ │ │ │ ├── mdns.h │ │ │ │ ├── mdns_opts.h │ │ │ │ ├── mdns_out.h │ │ │ │ ├── mdns_priv.h │ │ │ │ ├── mqtt.h │ │ │ │ ├── mqtt_opts.h │ │ │ │ ├── mqtt_priv.h │ │ │ │ ├── netbiosns.h │ │ │ │ ├── netbiosns_opts.h │ │ │ │ ├── smtp.h │ │ │ │ ├── smtp_opts.h │ │ │ │ ├── snmp_core.h │ │ │ │ ├── snmp.h │ │ │ │ ├── snmp_mib2.h │ │ │ │ ├── snmp_opts.h │ │ │ │ ├── snmp_scalar.h │ │ │ │ ├── snmp_snmpv2_framework.h │ │ │ │ ├── snmp_snmpv2_usm.h │ │ │ │ ├── snmp_table.h │ │ │ │ ├── snmp_threadsync.h │ │ │ │ ├── snmpv3.h │ │ │ │ ├── sntp.h │ │ │ │ ├── sntp_opts.h │ │ │ │ ├── tftp_client.h │ │ │ │ ├── tftp_common.h │ │ │ │ ├── tftp_opts.h │ │ │ │ └── tftp_server.h │ │ │ ├── arch.h │ │ │ ├── autoip.h │ │ │ ├── debug.h │ │ │ ├── def.h │ │ │ ├── dhcp6.h │ │ │ ├── dhcp.h │ │ │ ├── dns.h │ │ │ ├── err.h │ │ │ ├── errno.h │ │ │ ├── etharp.h │ │ │ ├── ethip6.h │ │ │ ├── icmp6.h │ │ │ ├── icmp.h │ │ │ ├── if_api.h │ │ │ ├── igmp.h │ │ │ ├── inet_chksum.h │ │ │ ├── inet.h │ │ │ ├── init.h │ │ │ ├── init.h.cmake.in │ │ │ ├── ip4_addr.h │ │ │ ├── ip4_frag.h │ │ │ ├── ip4.h │ │ │ ├── ip6_addr.h │ │ │ ├── ip6_frag.h │ │ │ ├── ip6.h │ │ │ ├── ip6_zone.h │ │ │ ├── ip_addr.h │ │ │ ├── ip.h │ │ │ ├── mem.h │ │ │ ├── memp.h │ │ │ ├── mld6.h │ │ │ ├── nd6.h │ │ │ ├── netbuf.h │ │ │ ├── netdb.h │ │ │ ├── netifapi.h │ │ │ ├── netif.h │ │ │ ├── opt.h │ │ │ ├── pbuf.h │ │ │ ├── priv │ │ │ │ ├── altcp_priv.h │ │ │ │ ├── api_msg.h │ │ │ │ ├── memp_priv.h │ │ │ │ ├── mem_priv.h │ │ │ │ ├── memp_std.h │ │ │ │ ├── nd6_priv.h │ │ │ │ ├── raw_priv.h │ │ │ │ ├── sockets_priv.h │ │ │ │ ├── tcpip_priv.h │ │ │ │ └── tcp_priv.h │ │ │ ├── prot │ │ │ │ ├── acd.h │ │ │ │ ├── autoip.h │ │ │ │ ├── dhcp6.h │ │ │ │ ├── dhcp.h │ │ │ │ ├── dns.h │ │ │ │ ├── etharp.h │ │ │ │ ├── ethernet.h │ │ │ │ ├── iana.h │ │ │ │ ├── icmp6.h │ │ │ │ ├── icmp.h │ │ │ │ ├── ieee.h │ │ │ │ ├── igmp.h │ │ │ │ ├── ip4.h │ │ │ │ ├── ip6.h │ │ │ │ ├── ip.h │ │ │ │ ├── mld6.h │ │ │ │ ├── nd6.h │ │ │ │ ├── tcp.h │ │ │ │ └── udp.h │ │ │ ├── raw.h │ │ │ ├── sio.h │ │ │ ├── snmp.h │ │ │ ├── sockets.h │ │ │ ├── stats.h │ │ │ ├── sys.h │ │ │ ├── tcpbase.h │ │ │ ├── tcp.h │ │ │ ├── tcpip.h │ │ │ ├── timeouts.h │ │ │ └── udp.h │ │ └── netif │ │ ├── bridgeif.h │ │ ├── bridgeif_opts.h │ │ ├── etharp.h │ │ ├── ethernet.h │ │ ├── ieee802154.h │ │ ├── lowpan6_ble.h │ │ ├── lowpan6_common.h │ │ ├── lowpan6.h │ │ ├── lowpan6_opts.h │ │ ├── ppp │ │ │ ├── ccp.h │ │ │ ├── chap-md5.h │ │ │ ├── chap_ms.h │ │ │ ├── chap-new.h │ │ │ ├── eap.h │ │ │ ├── ecp.h │ │ │ ├── eui64.h │ │ │ ├── fsm.h │ │ │ ├── ipcp.h │ │ │ ├── ipv6cp.h │ │ │ ├── lcp.h │ │ │ ├── magic.h │ │ │ ├── mppe.h │ │ │ ├── polarssl │ │ │ │ ├── arc4.h │ │ │ │ ├── des.h │ │ │ │ ├── md4.h │ │ │ │ ├── md5.h │ │ │ │ └── sha1.h │ │ │ ├── pppapi.h │ │ │ ├── pppcrypt.h │ │ │ ├── pppdebug.h │ │ │ ├── ppp.h │ │ │ ├── ppp_impl.h │ │ │ ├── pppoe.h │ │ │ ├── pppol2tp.h │ │ │ ├── ppp_opts.h │ │ │ ├── pppos.h │ │ │ ├── upap.h │ │ │ └── vj.h │ │ ├── slipif.h │ │ └── zepif.h │ └── netif │ ├── bridgeif.c │ ├── bridgeif_fdb.c │ ├── ethernet.c │ ├── FILES │ ├── lowpan6_ble.c │ ├── lowpan6.c │ ├── lowpan6_common.c │ ├── ppp │ │ ├── auth.c │ │ ├── ccp.c │ │ ├── chap-md5.c │ │ ├── chap_ms.c │ │ ├── chap-new.c │ │ ├── demand.c │ │ ├── eap.c │ │ ├── ecp.c │ │ ├── eui64.c │ │ ├── fsm.c │ │ ├── ipcp.c │ │ ├── ipv6cp.c │ │ ├── lcp.c │ │ ├── magic.c │ │ ├── mppe.c │ │ ├── multilink.c │ │ ├── polarssl │ │ │ ├── arc4.c │ │ │ ├── des.c │ │ │ ├── md4.c │ │ │ ├── md5.c │ │ │ ├── README │ │ │ └── sha1.c │ │ ├── pppapi.c │ │ ├── ppp.c │ │ ├── pppcrypt.c │ │ ├── PPPD_FOLLOWUP │ │ ├── pppoe.c │ │ ├── pppol2tp.c │ │ ├── pppos.c │ │ ├── upap.c │ │ ├── utils.c │ │ └── vj.c │ ├── slipif.c │ └── zepif.c ├── test │ ├── fuzz │ │ ├── config.h │ │ ├── fuzz2.c │ │ ├── fuzz3.c │ │ ├── fuzz.c │ │ ├── fuzz_common.c │ │ ├── fuzz_common.h │ │ ├── inputs │ │ │ ├── arp │ │ │ │ └── arp_req.bin │ │ │ ├── icmp │ │ │ │ └── icmp_ping.bin │ │ │ ├── ipv6 │ │ │ │ ├── neighbor_solicitation.bin │ │ │ │ └── router_adv.bin │ │ │ ├── tcp │ │ │ │ └── tcp_syn.bin │ │ │ └── udp │ │ │ └── udp_port_5000.bin │ │ ├── lwipopts.h │ │ ├── Makefile │ │ ├── output_to_pcap.sh │ │ └── README │ ├── sockets │ │ ├── sockets_stresstest.c │ │ └── sockets_stresstest.h │ └── unit │ ├── api │ │ ├── test_sockets.c │ │ └── test_sockets.h │ ├── arch │ │ ├── sys_arch.c │ │ └── sys_arch.h │ ├── core │ │ ├── test_def.c │ │ ├── test_def.h │ │ ├── test_dns.c │ │ ├── test_dns.h │ │ ├── test_mem.c │ │ ├── test_mem.h │ │ ├── test_netif.c │ │ ├── test_netif.h │ │ ├── test_pbuf.c │ │ ├── test_pbuf.h │ │ ├── test_timers.c │ │ └── test_timers.h │ ├── dhcp │ │ ├── test_dhcp.c │ │ └── test_dhcp.h │ ├── etharp │ │ ├── test_etharp.c │ │ └── test_etharp.h │ ├── Filelists.cmake │ ├── Filelists.mk │ ├── ip4 │ │ ├── test_ip4.c │ │ └── test_ip4.h │ ├── ip6 │ │ ├── test_ip6.c │ │ └── test_ip6.h │ ├── lwip_check.h │ ├── lwipopts.h │ ├── lwip_unittests.c │ ├── Makefile │ ├── mdns │ │ ├── test_mdns.c │ │ └── test_mdns.h │ ├── mqtt │ │ ├── test_mqtt.c │ │ └── test_mqtt.h │ ├── ppp │ │ ├── test_pppos.c │ │ └── test_pppos.h │ ├── tcp │ │ ├── tcp_helper.c │ │ ├── tcp_helper.h │ │ ├── test_tcp.c │ │ ├── test_tcp.h │ │ ├── test_tcp_oos.c │ │ ├── test_tcp_oos.h │ │ ├── test_tcp_state.c │ │ └── test_tcp_state.h │ └── udp │ ├── test_udp.c │ └── test_udp.h └── UPGRADING 145 directories, 719 files mancode@manos:~/objs/lwip-STABLE-2_2_0_RELEASE$
api文件夹源代码结构 为方便用户编程,LwIP为用户提供两种简单的高级API接口:协议栈sequentialAPI和socket API。这两种API实现的原理都是通过引进邮箱和信号量等通信与同步机制,来实现对内核中raw/callback API函数的封装和调用。也就是说,要使用这两种API,必须基于底层操作系统提供的邮箱和信号量机制,必须要在开发板上移植好操作系统。
文件
说明
api_lib.c
包含sequential API函数的实现,主要包含预留给用户的编程接口
api_msg.c
包含sequential API函数的实现,主要包含API消息的封装和处理函数
netbuf.c
包含上层数据包管理函数的实现
netdb.c
包含与主机名字转换相关的函数,主要在socket中被使用到
netifapi.c
包含上层网络接口管理函数的实现
sockets.c
包含socket API函数的实现
tcpip.c
提供了上层API与协议栈内核交互的函数,它是整个上层API功能得以实现的一个枢纽,其实现的功能可以理解为:从API函数处接收消息,然后将消息递交给内核函数,内核函数根据消息做出相应的处理。
netif文件夹源代码结构 netif文件夹主要包含了与底层网络接口相关的文件。
文件
说明
etharp.c
包含ARP协议的实现代码。主要用来实现主机以太网物理地址到IP地址的映射。
ethernetif.c
包含了与以太网网卡密切相关的初始化、发送、接收等函数的实现。这个文件夹中的函数并不能使用,它们都是一个框架性的结构,移植者需要根据自己使用的网卡特性来完成这些函数。
loopif.c
为协议栈提供回环网络接口功能。使用这个接口可以实现本地两个进程之间的数据传递。
slipif.c
SLIP(串行链路IP),提供一种在串行链路上传送IP数据包的函数定义,移植者需要根据自己使用的串行线路特性来实现这些函数。
core文件夹源代码结构 core文件夹是LwIP内核源代码,包含IP、ICMP、IGMP、TCP、UDP等核心协议以及建立在它们基础上的DNS、DHCP、SNMP等上层应用协议。内核源代码可以单独运行,且不需要操作系统的支持。我们先看下core根目录下的文件作用说明,然后再分析子目录中过的文件。
文件
说明
dhcp.c
包含DHCP(动态主机配置协议)客户端的实现代码
dns.c
包含DNS(域名系统)客户端的实现代码
init.c
包含了一个与LwIP协议栈初始化密切相关的函数,以及一些协议栈配置信息的检查与输出
mem.c
协议栈内存堆管理函数的实现代码
memp.c
协议栈内存池管理函数的实现代码
netif.c
包含协议栈网络接口管理的相关函数,协议栈内部对每个接口(比如以太网接口、回环接口等)用一个对应的数据结构进行描述,并通过使用netif.c中的函数进行统一管理。
pbuf.c
包含协议栈内核使用的数据包管理函数,用于协议栈层次间的数据传递,避免数据拷贝
raw.c
原始套接字的实现代码,可以通过该文件中的函数直接操纵IP层数据包
stats.c
包含协议栈内部数据统计与显示的函数,比如内存使用状况、邮箱、信号量等信息
sys.c
实现对操作系统模拟层的封装,为协议栈提供统一的邮箱、信号量操作函数。如果开发者需要使用协议栈的sequential API和socket API,则必须使用底层操作系统提供的邮箱与信号量机制,这时内核要求移植者提供一个称为sys_arch.c的操作系统模拟层文件,这个文件主要完成对操作系统中邮箱与信号量函数的封装。而sys.c文件的功能是将sys_arch.c中的函数再次封装,以得到具有协议栈特色的邮箱、信号量操作函数。所谓特色,就是在这些函数中加入一种机制,以实现协议栈中各个定时事件的正确处理。不使用sequential API和socket API时,开发者不需要再实现sys_arch.c中的函数,sys.c对内核来说也没用了,因为此时系统不需要任何邮箱和信号量机制。
tcp.c
包含对TCP控制块操作的函数,也包含了TCP定时处理函数
tcp_in.c
包含TCP协议数据接收、处理相关的函数,以及最重要的TCP状态机函数
tcp_out.c
包含TCP协议数据发送相关函数,例如数据包发送、超时重传函数等
udp.c
包含实现UDP协议的相关函数,包括控制块管理、数据包发送函数、数据包接收函数等
core/ipv4文件夹包含了IPv4标准中与IP层数据包处理相关的所有代码
文件
说明
autoip.c
包含IP地址自动配置相关函数,若主机从DHCP服务器处获取IP地址失败,则此时主机可以选择启动AUTOIP功能来配置自身的IP地址。AUTOIP将主机配置为169.254.0.0/16中的某个地址,并提供一套完整的机制来避免IP地址冲突
icmp.c
包含ICMP(网际控制报文协议)协议的实现代码。ICMP协议为IP数据包传递过程中的差错报告、差错纠正以及目的地址可达性测试提供了支持,常见的Ping命令就属于ICMP应用中的一种。
igmp.c
包含IGMP(网络组管理协议)协议的实现代码。IGMP为网络中的多播数据传输提供了支持,主机加入某个多播组后,可以接收到改组的UDP多播数据。
inet.c
包含IP层使用到的一些功能函数的定义,如IP地址的转换、网络字节序与主机字节序转换等
inet_chksum.c
包含对IP数据包校验相关的函数
ip.c
包含IPv4协议实现的相关函数,如数据包的接收、递交、发送等
ip_addr.c
包含一个判断IP地址是否为广播地址的函数
ip_frag.c
提供了IP层数据包分片与重组相关的函数
参考资料