ip _ dooptions function

We know ipintr call ip _ dooptions before the destination address of the packet is detected.
ip _ dooptions is passed a pointer m, a pointer to the packet, ip _ dooptions processing packet it
knows options. If ip _ dooptions forward the packet, such as when dealing with LSRR and SSRR options, or due to a
time error and drop the packet, it returns 1. If it does not forward packets, ip _ dooptions returns 0, followed by the ipintr
continue processing the packet.
ip _ dooptions is a long function, so we will step through the display. The first part of the initialization for a loop,
the processing of the options header.
When processing each option, cp points to the first byte of the option. Figure 9 - 7 shows, when available, how often cp from the
displacement of the traffic type, length and offset fields.

RFC the displacement (offset) pointer field as described (pointer), the pointer is slightly stronger than the displacement of some description. The value of offset is
a byte sequence number in the option (type from the beginning, No. 1), not from the beginning of the type, and to start a count of zero.
The minimum displacement is 4 (IPOPT _ MINOFF), which points to the first byte of a multi-byte data field options.
FIG shows an overall configuration ip _ dooptions function.
5 5 5 - 5 6 6 ip _ dooptions the ICMP error type type is initialized to ICMP _ PARAMPROB, not for any
This is a general error values are specific types of errors. For ICMP _ PARAMPROB, code refers to the bytes of error
within the packet displacement. This is the default ICMP error messages. Some options will change these values.
ip ip points to a 20 byte size configuration, so that ip + 1 is the next point to behind the IP header followed
ip structure. Because ip _ dooptions need behind the IP header byte address, so put pointer conversion result
becomes a point unsigned byte (u _ char) pointer. Therefore, cp point other than the standard IP header of the first
byte is the first byte of the IP options.


1. EOL process and NOP


5 6 7 - 5 8 2 for each cycle processed in the order they appear in the options for each packet. EOL options and
an invalid option length (ie option length option data show that over the IP header) will terminate the cycle. When NOP appears
option, ignore it. default case in a switch statement implicitly requires the system to ignore unknown options.
The following describes each option switch statement processing. If ip _ dooptions packet processing options
without errors, passes control to the following code swi tc h.

2. Source Routing forwarding

719--724 If the packet needs to be forwarded, SSRR option LSRR or processing code is set to put forward. Packet is transmitted
to the ip _ forward, and the second parameter to 1, indicates that the packet is based on source routing.

3. error handling


725--730 If an error occurs in the switch statement inside, ip _ dooptions jump bad. From the packet length in
the IP header length minus, because icmp _ error is assumed that the header length is not included in the packet length. icmp _ error sent
the appropriate error message, ip _ dooptions 1 returns, to avoid ipintr processing packets discarded.

Guess you like

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