Tải bản đầy đủ - 0 (trang)
044 - 3.7 Network Initialization Overview

044 - 3.7 Network Initialization Overview

Tải bản đầy đủ - 0trang

Figure3.22.pdevinitstructure.



120-123

InthepdevinitstructuresfortheSLIPand

theloopbackinterface,pdev_attachisset

toslattachandloopattachrespectively.

Whentheattachfunctioniscalled,

pdev_countispassedastheonly

argumentandspecifiesthenumberof

devicestocreate.Onlyoneloopback

deviceiscreatedbutmultipleSLIPdevices

maybecreatediftheadministrator

configurestheSLIPentryaccordingly.

Thenetworkinitializationfunctionsfrom

mainareshowninFigure3.23.



Figure3.23.mainfunction:network

initialization.







70-96

cpu_startuplocatesandinitializesallthe

hardwaredevicesconnectedtothe

system,includinganynetworkinterfaces.

97-174

Afterthekernelinitializesthehardware

devices,itcallseachofthepdev_attach

functionscontainedwithinthepdevinit

array.

175-234



ifinitanddomaininitfinishtheinitialization

ofthenetworkinterfacesandprotocols

andschedulerbeginsthekernelprocess

scheduler,ifinitanddomaininitare

describedinChapter7.

Inthefollowingsectionswedescribethe

initializationoftheEthernet,SLIP,and

loopbackinterfaces.



Team-Fly









Top



Team-Fly











TCP/IPIllustrated,Volume2:The

ImplementationByGaryR.Wright,

W.RichardStevens

TableofContents



Chapter3.InterfaceLayer



3.8EthernetInitialization

Aspartofcpu_startup,thekernellocates

anyattachednetworkdevices.Thedetails

ofthisprocessarebeyondthescopeof

thistext.Onceadeviceisidentified,a

device-specificinitializationfunctionis

called.Figure3.24showstheinitialization

functionsforourthreesampleinterfaces.



Figure3.24.Networkinterface

initializationfunctions.



Eachdevicedriverforanetworkinterface

initializesaspecializedifnetstructureand

callsif_attachtoinsertthestructureinto

thelinkedlistofinterfaces.Thele_softc

structureshowninFigure3.25isthe

specializedifnetstructureforoursample

Ethernetdriver(Figure3.20).



Figure3.25.le_softcstructure.



le_softcstructure

69-95

Anarrayofle_softcstructures(withNLE

elements)isdeclaredinif_le.c.Each

structurestartswithsc_ac,anarpcom

structurecommontoallEthernet

interfaces,followedbydevice-specific

members.Thesc_ifandsc_addrmacros



simplifyaccesstotheifnetstructureand

Ethernetaddresswithinthearpcom

structure,sc_ac,showninFigure3.26.



Figure3.26.arpcomstructure.



arpcomstructure

95-101

Thefirstmemberofthearpcomstructure,

ac_if,isanifnetstructureasshownin

Figure3.20.ac_enaddristheEthernet

hardwareaddresscopiedbytheLANCE

devicedriverfromthehardwarewhenthe

kernellocatesthedeviceduring

cpu_startup.Foroursampledriver,this

occursintheleattachfunction(Figure

3.27).ac_ipaddristhelastIPaddress

assignedtothedevice.Wediscussaddress

assignmentinSection6.6,wherewe'llsee



thataninterfacecanhaveseveralIP

addresses.SeealsoExercise6.3.

ac_multiaddrsisalistofEthernet

multicastaddressesrepresentedby

ether_multistructures.ac_multicntcounts

theentriesinthelist.Themulticastlistis

discussedinChapter12.



Figure3.27.leattachfunction.







106-115

Figure3.27showstheinitializationcode

fortheLANCEEthernetdriver.

Thekernelcallsleattachonceforeach

LANCEcarditfindsinthesystem.

Thesingleargumentpointstoan



hp_devicestructure,whichcontainsHPspecificinformationsincethisdriveris

writtenforanHPworkstation.

lepointstothespecializedifnetstructure

forthecard(Figure3.20)andifppointsto

thefirstmemberofthatstructure,sc_if,a

genericifnetstructure.Thedevice-specific

initializationsarenotincludedinFigure

3.27andarenotdiscussedinthistext.



Copythehardwareaddressfromthe

device

126-137

FortheLANCEdevice,theEthernet

addressassignedbythemanufactureris

copiedfromthedevicetosc_addr(which

issc_ac.ac_enaddrseeFigure3.26)one

nibble(4bits)atatimeinthisforloop.

lestdisadevice-specifictableofoffsets

tolocateinformationrelativeto

hp_addr,whichpointstoLANCE-specific

information.

Thecompleteaddressisoutputtothe



consolebytheprintfstatementtoindicate

thatthedeviceexistsandisisoperational.



Initializetheifnetstructure

150-157

leattachcopiesthedeviceunitnumber

fromthehp_devicestructureintoif_unit

toidentifymultipleinterfacesofthesame

type.if_nameis"le"forthisdevice;if_mtu

is1500bytes(ETHERMTU),themaximum

transmissionunitforEthernet;if_init,

if_reset,if_ioctl,if_output,andif_startall

pointtodevice-specificimplementationsof

thegenericfunctionsthatcontrolthe

networkinterface.Section4.1describes

thesefunctions.

158

AllEthernetdevicessupport

IFF_BROADCAST.TheLANCEdevicedoes

notreceiveitsowntransmissions,so

IFF_SIMPLEXisset.Thedriverand

hardwaresupportsmulticastingso

IFF_MULTICASTisalsoset.



159-162

bpfattachregisterstheinterfacewithBPF

andisdescribedwithFigure31.8.The

if_attachfunctioninsertstheinitialized

ifnetstructureintothelinkedlistof

interfaces(Section3.11).



Team-Fly









Top



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

044 - 3.7 Network Initialization Overview

Tải bản đầy đủ ngay(0 tr)

×