Tải bản đầy đủ - 0 (trang)
11 raw_attach, raw_detach, and raw_disconnect Functions

11 raw_attach, raw_detach, and raw_disconnect Functions

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

49-64

Thecallermusthavealreadyallocatedthe

rawprotocolcontrolblock.soreservesets

thehigh-watermarksforthesendand

receivebuffersto8192.Thisshouldbe

morethanadequatefortherouting

messages.

65-67

Apointertothesocketstructureisstored

intheprotocolcontrolblockalongwiththe

dom_family(whichisPF_ROUTEfrom

Figure20.1fortheroutingdomain)and

theprotoargument(whichisthethird

argumenttosocket).







68-70

insqueaddsthecontrolblocktothefront

ofthedoublylinkedlistheadedbythe

globalrawcb.

Theraw_detachfunction,showninFigure

20.25,wascalledbyraw_inputtofinish

processingthePRU_DETACHrequest.



Figure20.25.raw_detachfunction.



75-84

Theso_pcbpointerinthesocketstructure

issettonullandthesocketisreleased.

Thecontrolblockisremovedfromthe

doublylinkedlistbyremqueandthe

memoryusedforthecontrolblockis

releasedbyfree.



Theraw_disconnectfunction,shownin

Figure20.26,wascalledbyraw_inputto

processthePRU_DISCONNECTand

PRU_ABORTrequests.



Figure20.26.raw_disconnectfunction.



88-94

Ifthesocketdoesnotreferencea

descriptor,raw_detachreleasesthesocket

andcontrolblock.



Team-Fly









Top



Team-Fly











TCP/IPIllustrated,Volume2:The

ImplementationByGaryR.Wright,

W.RichardStevens

TableofContents



Chapter20.RoutingSockets



20.12Summary

Aroutingsocketisarawsocketinthe

PF_ROUTEdomain.Routingsocketscanbe

createdonlybyasuperuserprocess.Ifa

nonprivilegedprocesswantstoreadthe

routinginformationcontainedinthe

kernel,thesysctlsystemcallsupportedby

theroutingdomaincanbeused(we

describedthisinthepreviouschapter).

Thischapterwasourfirstencounterwith

theprotocolcontrolblocks(PCBs)thatare

normallyassociatedwitheachsocket.In

theroutingdomainaspecialrawcb

containsinformationabouttherouting

socket:thelocalandforeignaddresses,

theaddressfamily,andtheprotocol.We'll



seeinChapter22thatthelargerInternet

protocolcontrolblock(inpcb)isusedwith

UDP,TCP,andrawIPsockets.The

conceptsarethesame,however:the

socketstructureisusedbythesocket

layer,andthePCB,arawcboraninpcb,is

usedbytheprotocollayer.Thesocket

structurepointstothePCBandviceversa.

Theroute_outputfunctionhandlesthefive

routingrequeststhatcanbeissuedbya

process.raw_inputdeliversarouting

messagetooneormoreroutingsockets,

dependingontheprotocolandaddress

family.ThevariousPRU_xxxrequestsfora

routingsocketarehandledbyraw_usrreq

androute_usrreq.Inlaterchapterswe'll

encounteradditionalxxx_usrreqfunctions,

oneperprotocol(UDP,TCP,andrawIP),

eachconsistingofaswitchstatementto

handleeachrequest.



Exercises



Listtwowaysaprocesscanreceive

thereturnvaluefromroute_output







20.1 whentheprocesswritesamessage

toaroutingsocket.Whichmethodis

morereliable?

Whathappenswhenaprocess

specifiesanonzeroprotocol

20.2 argumenttothesocketsystemcall,

sincethepr_protocolmemberofthe

routeswstructureis0?

Routesintheroutingtable(other

20.3 thanARPentries)nevertimeout.

Implementatimeoutonroutes.



Team-Fly









Top



Team-Fly



TCP/IPIllustrated,Volume2:The

ImplementationByGaryR.Wright,

W.RichardStevens

TableofContents











Chapter21.ARP:Address

ResolutionProtocol

Section21.1.Introduction

Section21.2.ARPandtheRouting

Table

Section21.3.CodeIntroduction

Section21.4.ARPStructures

Section21.5.arpwhohasFunction

Section21.6.arprequestFunction

Section21.7.arpintrFunction





Section21.8.in_arpinputFunction

Section21.9.ARPTimerFunctions

Section21.10.arpresolveFunction

Section21.11.arplookupFunction

Section21.12.ProxyARP



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

11 raw_attach, raw_detach, and raw_disconnect Functions

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

×