Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AddIP_RECVTTL andIP_RECVERR constants tosocket module #120056

Closed
Assignees
sobolevn
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
@sobolevn

Description

@sobolevn

Feature or enhancement

I recently needed these three constants in a real code, I had to create them manually.

Docs from Linux:https://man7.org/linux/man-pages/man7/ip.7.html

IP_RECVERR (sinceLinux2.2)Enableextendedreliableerrormessagepassing.Whenenabledonadatagramsocket,allgeneratederrorswillbequeuedinaper-socketerrorqueue.Whentheuserreceivesanerrorfromasocketoperation,theerrorscanbereceivedbycalling [recvmsg(2)](https://man7.org/linux/man-pages/man2/recvmsg.2.html) with the MSG_ERRQUEUEflagset.Thesock_extended_errstructuredescribingtheerrorwillbepassedinanancillarymessagewiththetypeIP_RECVERRandthelevelIPPROTO_IP.Thisisusefulforreliableerrorhandlingonunconnectedsockets.Thereceiveddataportionoftheerrorqueuecontainstheerrorpacket.TheIP_RECVERRcontrolmessagecontainsasock_extended_errstructure:#defineSO_EE_ORIGIN_NONE0#defineSO_EE_ORIGIN_LOCAL1#defineSO_EE_ORIGIN_ICMP2#defineSO_EE_ORIGIN_ICMP63structsock_extended_err {uint32_tee_errno;/* error number */uint8_tee_origin;/* where the error originated */uint8_tee_type;/* type */uint8_tee_code;/* code */uint8_tee_pad;uint32_tee_info;/* additional information */uint32_tee_data;/* other data *//* More data may follow */                  };structsockaddr*SO_EE_OFFENDER(structsock_extended_err*);ee_[errno](https://man7.org/linux/man-pages/man3/errno.3.html) contains the errno number of the queued error.ee_originistheorigincodeofwheretheerrororiginated.Theotherfieldsareprotocol-specific.ThemacroSO_EE_OFFENDERreturnsapointertotheaddressofthenetworkobjectwheretheerrororiginatedfromgivenapointertotheancillarymessage.Ifthisaddressisnotknown,thesa_familymemberofthesockaddrcontainsAF_UNSPECandtheotherfieldsofthesockaddrareundefined.IPusesthesock_extended_errstructureasfollows:ee_originissettoSO_EE_ORIGIN_ICMPforerrorsreceivedasanICMPpacket,orSO_EE_ORIGIN_LOCALforlocallygeneratederrors.Unknownvaluesshouldbeignored.ee_typeandee_codearesetfromthetypeandcodefieldsoftheICMPheader.ee_infocontainsthediscoveredMTUforEMSGSIZEerrors.Themessagealsocontainsthesockaddr_inofthenodecausedtheerror,whichcanbeaccessedwiththeSO_EE_OFFENDERmacro.Thesin_familyfieldoftheSO_EE_OFFENDERaddressisAF_UNSPECwhenthesourcewasunknown.Whentheerrororiginatedfromthenetwork,allIPoptions (IP_OPTIONS,IP_TTL,etc.)enabledonthesocketandcontainedintheerrorpacketarepassedascontrolmessages.Thepayloadofthepacketcausingtheerrorisreturnedasnormalpayload.NotethatTCPhasnoerrorqueue;MSG_ERRQUEUEisnotpermittedonSOCK_STREAMsockets.IP_RECVERRisvalidforTCP,butallerrorsarereturnedbysocketfunctionreturnorSO_ERRORonly.Forrawsockets,IP_RECVERRenablespassingofallreceivedICMPerrorstotheapplication,otherwiseerrorsarereportedonlyonconnectedsocketsItsetsorretrievesanintegerbooleanflag.IP_RECVERRdefaultstooff.IP_RECVTTL (sinceLinux2.2)Whenthisflagisset,passaIP_TTLcontrolmessagewiththetime-to-livefieldofthereceivedpacketasa32bitinteger.NotsupportedforSOCK_STREAMsockets.

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp