ip _ insertoptions function

ip _ output function option and receiving a packet. Ip _ forward when the function is called
, the option is already part of the group, so ip _ forward always to pass a null pointer option ip _ output.
However, the transport layer protocols may put the ip _ insertoptions the ip _ output to call the merged
packet options to the ip _ forward. ip _ insertoptions desired option is formatted ipoption structure, as shown in FIG.

92--95 only two members of the structure: ipopt _ dst, if the option is active routing table, wherein a first hop of the object
to, ipopt _ list, is a maximum of 4 0 (MAX _ IPOPTLEN) bytes options matrix, the format we in this chapter
have been described. If the option is no source routing table, the ipopt _ dst all zeros.
Note, ip _ srcrt structure and returned by ip _ srcroute of mbuf are in line with the
ipoption structure specified format. The structures are compared in FIG ip _ srcrt and ipoption.

Ip _ insertoptions function shown in FIG.

3 5 2 - 3 6 4 ip _ insertoptions three parameters: m, outgoing packet; opt, formatted in the configuration option
item; phlen, a pointer to an integer, where returns the length of a new header (the insertion option after that). If the insertion
option packet length exceeds the maximum packet length of 65 535 (IP _ MAXPACKET) bytes, then the option is automatically discarded.
ip _ dooptions think ip _ insertoptions will never fail, so I can not report errors. Fortunately, very
few application attempts to send packets of maximum length, not to mention the option.

365--. 366 If ipopt _ dst s _ addr specifies a non-zero address, comprising a source routing option, and

DST IP packet header _ source route is replaced by a first hop destination.
FIG displayed prior to the 367 ~ 378 lines of code execution, a configuration mbuf the TCP segment.

 

If the option is inserted into the number of bytes occupied more than 16, the test of row 367 is true, and call MGETHDR points
with another mbuf. The figure above shows the options are copied to the new mbuf, the cache structure.
367--378 if the packet header is stored in the cluster, or the first buffer is no room in extra option, the
allocation of a new packet header mbuf ip _ insertoptions, initializes its length, from the old cache to the IP
header taken down and moved to the first portion from the old to the new cache buffer.

Guess you like

Origin www.cnblogs.com/momenglin/p/11518571.html