Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
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.