Tải bản đầy đủ - 0 (trang)
7 Initialization: route_init and rtable_init Functions

7 Initialization: route_init and rtable_init Functions

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

ThePF_ROUTEdomainistheonlyonewith

aninitializationfunction.Also,onlythe

domainsthatrequirearoutingtablehave

adom_rtattachfunction,anditisalways

rn_inithead.Theroutingdomainandthe

Unixdomainprotocolsdonotrequirea

routingtable.

Thedom_rtoffsetmemberistheoffset,in

bits,(fromthebeginningofthedomain's

socketaddressstructure)ofthefirstbitto

beexaminedforrouting.Thesizeofthis

structureinbytesisgivenby

dom_maxrtkey.Wesawearlierinthis

chapterthattheoffsetoftheIPaddressin

thesockaddr_instructureis32bits.The

dom_maxrtkeymemberisthesizein

bytesoftheprotocol'ssocketaddress

structure:16forsockaddr_in.

Figure18.29outlinesthestepsinvolvedin

initializingtheroutingtables.



Figure18.28.Summaryofrouting

structures.







Figure18.29.Stepsinvolvedin

initializationofroutingtables.



domaininitiscalledoncebythekernel's

mainfunctionwhenthesystemis

initialized.Thelinkedlistofdomain

structuresisbuiltbytheADDDOMAIN

macroandthelinkedlististraversed,

callingeachdomain'sdom_initfunction,if



defined.AswesawinFigure18.27,the

onlydom_initfunctionisroute_init,which

isshowninFigure18.30.



Figure18.30.route_initfunction.



Thefunctionrn_init,showninFigure

18.32,iscalledonlyonce.

Thefunctionrtable_init,showninFigure

18.31,isalsocalledonlyonce.Itinturn

callsallthedom_rtattachfunctions,which

initializearoutingtabletreeforthat

domain.



Figure18.31.rtable_initfunction:call

eachdomain'sdom_rtattachfunction.



WesawinFigure18.27thattheonly

dom_rtattachfunctionisrn_inithead,

whichwedescribeinthenextsection.



Team-Fly









Top







Team-Fly







TCP/IPIllustrated,Volume2:The

ImplementationByGaryR.Wright,

W.RichardStevens

TableofContents



Chapter18.RadixTreeRouting

Tables



18.8Initialization:rn_initand

rn_initheadFunctions

Thefunctionrn_init,showninFigure

18.32,iscalledoncebyroute_initto

initializesomeoftheglobalsusedbythe

radixfunctions.



Figure18.32.rn_initfunction.



Determinemax_keylen

750-761

Allthedomainstructuresareexamined

andtheglobalmax_keylenissettothe

largestvalueofdom_maxrtkey.InFigure

18.27thelargestvalueis32forAF_ISO,

butinatypicalsystemthatexcludesthe

OSIandXNSprotocols,max_keylenis16,

thesizeofasockaddr_instructure.



Allocateandinitializern_zeros,rn_ones,

andmaskedKey

762-769

Abufferthreetimesthesizeof



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

7 Initialization: route_init and rtable_init Functions

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

×