Skip to Content
Understanding Linux Network Internals
book

Understanding Linux Network Internals

by Christian Benvenuti
December 2005
Intermediate to advanced
1066 pages
33h 38m
English
O'Reilly Media, Inc.
Content preview from Understanding Linux Network Internals

Data Structures Featured in This Chapter

The three main data structures used by the ICMP code are:

icmphdr

ICMP header .

icmp_control

ICMP message type descriptor. Among its fields is the routine used to process ingress messages.

icmp_bxm

Input structure given as a parameter to the two transmit routines described in the section "Transmitting ICMP Messages." It includes all the information necessary to transmit an ICMP message.

icmphdr Structure

We saw in Figure 25-1 the structure of an ICMP message. The following, from include/linux/icmp.h, is the data structure used to define an ICMP header:

    struct icmphdr {
      _ _u8    type;
      _ _u8    code;
      _ _u16    checksum;
      union {
            struct {
                _ _u16    id;
                _ _u16    sequence;
            } echo;
            _ _u32    gateway;
            struct {
                _ _u16    _ _unused;
                _ _u16    mtu;
            } frag;
      } un;
    };

First come the three fields common to all ICMP types, and then a union that provides different fields based on the message type. For example, un.frag is used by ICMP_FRAG_NEEDED messages, and un.echo by the query messages (i.e., ICMP_ECHO, ICMP_ECHOREPLY, etc.).

icmp_control Structure

For each ICMP type there is an instance of an icmp_control data structure (defined in net/ipv4/icmp.c). Among other fields, it includes a pointer to the routine that is to be called to process ingress ICMP messages. Here are its fields:

int output_entry
int input_entry

Indexes used by the receive routine icmp_rcv and the transmission routines in the section "Transmitting ICMP Messages" to update the right SNMP counter in an array. See ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Linux Kernel Debugging

Linux Kernel Debugging

Kaiwan N. Billimoria
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria

Publisher Resources

ISBN: 0596002556Errata Page