LWIP用户手册.docx
- 文档编号:17027019
- 上传时间:2023-07-21
- 格式:DOCX
- 页数:30
- 大小:340.42KB
LWIP用户手册.docx
《LWIP用户手册.docx》由会员分享,可在线阅读,更多相关《LWIP用户手册.docx(30页珍藏版)》请在冰点文库上搜索。
LWIP用户手册
DevelopingApplicationsusinglwIPTCP/IPstackonADI-BF533,andADI-BF537processors
Tableofcontents
1.Introduction2
2.DevelopinganetworkapplicationwithlwIPandVDK3
2.1.UsethesocketAPIheaderfile4
2.2.Ensuringthatsemaphorescanbecreated4
2.3.InitializetheSSLinterruptanddevicedrivermanagers5
2.4.Initializeandsetupthekernelapilibrary5
2.5.OpenthedevicedriverfortheEthernetMACcontroller5
2.6.ConfigureEBIUcontrollertogiveDMApriorityoverprocessor5
2.7.SupplytheMACaddressthatitistobeusedtothedevicedriver6
2.8.SupplymemorytotheEthernetdevicedriver6
2.9.NotifythedevicedriverlibrarythattheEthernetdriverwillusetheDataflowmethod6
2.10.InitializeandconfigurethelwIPstack6
2.11.NotifytheEthernetdriverthatitshouldnowstarttooperate.6
2.12.Waitforthephysicallinktobeestablished7
3.ThelwIPstackelements7
4.BuildingthelwIPstackwithcustomoptions7
4.1.lwIPmemoryconfiguration8
5.TCP/IPConfigurationPlugin9
5.1.Theoperationoftheplugin9
5.2.Usingtheplugin10
5.2.1.Generalpage11
5.2.2.IPpage12
5.2.3.Network0page13
5.2.4.Network1page14
5.2.5.TCP/UDP/ARPpage15
5.2.6.Debugpage16
5.2.7.Memorypage17
6.SocketAPIandotherDocumentation.17
7.TCP/IPexamples18
7.1.DNSClient18
7.2.inetdserver18
7.3.FileServerapplication19
7.3.1.FileServerhostapplication19
7.3.2.FileServerBlackfinexample21
7.4.Webserver21
7.5.TCP/IPTracing21
7.5.1.TracingoverBTC23
7.5.2.TracingoverTCP/IP24
Introduction
ThelwIPTCP/IPstackpackageonAnalogDevicesBlackfinfamilyofprocessorsconsistsofthefreelyavailablelwIPstack.TheportedstackusesastandardizeddriverinterfacetoallowittobeusedwithdifferentEthernetcontrollers.ThedriversareallimplementedaspartofthePTGdrivermodelandusestheSystemServicesLibraries(SSL).FormoreinformationonlwIPstackvisithttp:
//www.sics.se/~adam/lwIP/,thesourcesforthestackaremaintainedathttp:
//savannah.nongnu.org/cgi-bin/viewcvs/lwIP/lwIP/
ThestackprovidesthestandardBSDsocketAPItotheapplicationandhasbeenstructuredtodecoupleitfromboththeoperatingenvironmentandthespecificnetworkinterfacebeingused.Thestackisconnectedtothesurroundingenvironmentbymeansoftwostandardizedinterfaceswhichareimplementedasadifferentlibraryforeachseparateenvironment
∙ThekernelAPIabstractstheprimitiveoperatingsystemservicesandfacilitatesthatthestackrequiresandisusedtosimplifythemigrationofapplicationstodifferentoperatingsystemenvironments.Thebasicservicesincludesynchronizationservices,interruptservices,andtimerbasedcallbackservices.Thekervdkbfxxx.dlblibrariesprovideanimplementationoftheinterfacetoenablethestacktobeusedwithVDKonthevariousBlackfinprocessors.Thestackcanbeusedwithotherkernelsbyprovidinganimplementationofthekernelapiinterfacefortherequiredkernelandprocessor.
ThekernelAPIisdefinedinthedocumentkernel_api.htmlwhichisheldinthe
∙ThestackcansupportanyEthernetcontrollerwhichhasadriverthatsupportsthedriverinterfacethatisdefinedinthefileEtherDeviceDriverDefinition.docwhichisheldinthe
oTheBlackfinBF537EthernetMACcontroller
oTheBlackfinUSBLANEZ-ExtendercardwhichusestheSMSCLAN91C111Ethernetcontroller
VisualDSP++4.0providesawizardwhichwillcreateaVDKprojectwithTCP/IPsupportbuiltinandreadytouse.ThestandardBSDsocketsAPIisthemainprogramminginterfacethatthestackprovidestotheapplication.Thedetailsofthesocketinterfacecanbeaccessedbyopeningthefileindex.htmlwhichisinthe
TheconfigurationofthestackcanbeeffectedusingasuppliedVisualDSPpluginthatwillgenerateatailoredheaderfileandaninitialisedCstructurethatthestackuses.Thepluginallowsthemainconfigurationparameterstobemodified.AlternativelythestackcanbefullyconfiguredbymodifyingthestandardlwIPheaderfilesmanually.
SupportisalsoprovidedtoallowthetracingofframessentandreceivedbythestackeitherdirectlyontheBlackfinprocessorortoahostbasedapplicationusingaTCP/IPconnectionortheBackgroundTelemetryChannel.
Thestacksupportsthefollowingprotocols
TCPTransportControlProtocol
UDPUserDatagramProtocol
IPInternetProtocol
ICMPInternetControlMessageProtocol
ARPAddressResolutionProtocol
DHCPDynamicHostConfigurationProtocol(DHCPclientsupportingBOOTP)
ADNSclientimplementationisalsoavailableasanexample.
OneoftheprincipalaimswhenportingthestackwastominimizethechangesthatwererequiredtobemadetothesourcesoftheactuallwIPstacktoenablesubsequentstackupdatestobeintegratedeasily.Themainchangesthatweremadeareoutlinedbelow
∙Basememoryallocationwaschangedfromstaticarraystoenableittobedynamicallyallocatedwhenthestackwasbeinginitialized.
∙Theprocedureusedtosetperthreadsocketerrors
∙Addedanadditionalfieldtosomestructurestoensurecorrectalignment
Allofthechangesmadetothestackareunderthecontrolofthepre-processorvariable__ADSPBLACKFIN__.
ThesourcesforthelwIPstackareprovidedunderaBSDstylelicensewhosetermsareincludedintheVisualDSP++licenseterms.
DevelopinganetworkapplicationwithlwIPandVDK
ThesimplestwayofcreatinganapplicationthatusesthelwIPstackistousetheprojectcreationwizardandselecttheprojecttypeas“TCP/IPStackapplicationusingLwIPandVDK”.Thecreatedprojectwillincorporateeverythingneededforthestackandwillalsocreateabootthreadthatwilltakethenecessarystepstoinitializethestackandthedriversthatitmayneed.
ItispossibletoaddsupportforthestacktoanexistingVDKapplicationandthestepsneededtodothisaredescribedbelow.Thecodegeneratedbytheprojectwizardcanbeincorporatedintoanexistingapplicationtosimplifyintegratingsupport.
AnapplicationthatwishestousethelwIPstackwithVDKisresponsibleforcreatingaVDKthreadtypethatthelwIPstackwillusetocreateanythreadsthatitrequiresduringoperation.TheapplicationalsohastoinitializesomeSystemServiceLibrarycomponentsaswellascreatinganinstanceofthedriverfortheappropriateEthernetcontroller.
ThestepsinvolvedincreatinganapplicationthatusesthelwIPstackcanbesummarizedas:
1.SpecifyingandusingtheheaderfileforthesocketAPI.
2.EnsurethatsufficientVDKsemaphoresareconfigured
3.InitializetheSSLinterruptanddevicedrivermanagers
4.Initializeandsetupthekernelapilibrary
5.OpenthedevicedriverfortheEthernetMACcontrollerandpassthehandleforthedrivertothelwIPstack
6.ConfigureEBIUcontrollertogiveDMApriorityoverprocessor
7.SupplytheMACaddressthatitistobeusedtothedevicedriver
8.Supplymemorytothedevicedrivertoenableittosupporttheappropriatenumberofsimultaneousreadsandwrite
9.NotifythedevicedriverlibrarythattheEthernetdriverwillusetheDataflowmethod
10.InitializeandconfigurethelwIPstacksupplyingmemoryforthestacktouseasitsinternalheap
11.NotifytheEthernetdriverthatitshouldnowstarttooperate
12.Waitforthephysicallinktobeestablished
UsethesocketAPIheaderfile
Theheaderfileslwip\sockets.handlwip\inet.hdefinetheavailableBSDsocketAPIandshouldbeincludedinthesourcefilesofanyapplicationthatusesthestack.
Ensuringthatsemaphorescanbecreated
InthekerneltabyoumustalsoensurethatundertheSemaphoresentry,the“MaximumActiveSemaphores”valueisincreasedsufficientlytoallowthestacktocreateanysemaphoresitneedstoeffectsynchronizationbetweenthreads.Inadditiontothenumberofsemaphoresthattheapplicationitselfneedsyoushouldallowfor:
∙foursemaphoresforthestackitself
∙onesemaphoreforeachsimultaneouslyopenedsocket
InitializetheSSLinterruptanddevicedrivermanagers
TheSSLinterruptmanagerisinitializedwithacallonthefunctionadi_int_Initandyoumustsupplysomememoryforittouse.Thesuppliedmemoryisusedtoenablemultipledevicestobeassociatedwitheachinterruptlevel.
TheSSLdevicedrivermanagerisinitializedwithacallonthefunctionadi_int_Devandyoumustsupplysomememoryforittouse.Thesuppliedmemoryisusedtosupportmultiplesimultaneouslyopendevicedrivers.ThecallalsoreturnsahandleforthedevicedrivermanagerthatmustbeusedwhenyouopentheEthernetdevicedriver.
Initializeandsetupthekernelapilibrary
ThekernelapilibraryisusedtointerfacethestacktotheparticularOSthatisbeingused.Thekernellibrarymustbeinitializedbyacallonthefunctionker_init.Currentlythepassedparametershouldalwaysbezero.Afterthelibraryhasbeenopenedtheker_set_auxdatafunctioniscalledtonotifythelibraryoftheVDKthreadtypeidentifieritshouldusewhenthestackneedstocreateathread.
OpenthedevicedriverfortheEthernetMACcontroller
ThedevicedriverfortheEthernetMACcontrollerisopenedbycallingthefunctionadi_de
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- LWIP 用户手册