How to send IPv6 DSTOPTS extension header with IPv6 Option over TCP socket

Solution Verified - Updated -

Issue

This article describes the client side of using IPv6 Extension headers over TCP socket.
The server side is described in article 717133:
How to recv IPv6 DSTOPTS extension header with IPv6 Option over TCP?

A TCP client wants to attach to each outgoing packet an IPv6 Extension header.
The header type should be "Destination options header" IPPROTO_DSTOPTS.
The header should contain one "IPv6 Option" with a specific self-defined option type and data.

The option should carry structure of the type "dst_opt_tlv_t" defined below:

typedef struct {
    uint16_t port;        
    uint16_t vrf;
    uint8_t  flags;                                         
    uint8_t  reserved[3];
    uint8_t  addr8[16];
} dst_opt_tlv_data_t;

typedef struct {
    uint8_t padn;
    uint8_t len;
    uint8_t data[8];
} dst_opt_tlv_pad_t;

typedef struct {
    dst_opt_tlv_data_t data;
    dst_opt_tlv_pad_t pad;
} dst_opt_tlv_t;

With custom data:

Option type 0x1f:
  ndst_opt_tlv_t:
    dst_opt_tlv_data_t:
      port      0x80
      vrf       0x11
      flags     0x00
      reserved  [00 00 00]
      addr8 [00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f]
    dst_opt_tlv_pad_t:
      padn 0x01
      len  0x02
      data [00 00]

Environment

Red Hat Enterprise Linux (RHEL) 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content