<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
<?rfc toc="yes" ?>
<?rfc tocompact="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc comments="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc strict="yes" ?>
<rfc category="exp"
  ipr="full3978"
  docName="draft-denis-behave-v4v6exthdr-00">

  <front>
    <title abbrev="IPv6v4 mapping option">
      IPv6 destination header option for
      IPv4 translator mapping notification</title>
    <author initials="R." surname="Denis-Courmont"
        fullname="R&eacute;mi Denis-Courmont">
      <organization abbrev="Nokia">Nokia Corporation</organization>
      <address>
        <postal>
          <street>P.O. Box 407</street>
          <city>NOKIA GROUP</city>
          <code>00045</code>
          <country>FI</country>
        </postal>
        <phone>+358 50 487 6315</phone>
        <email>remi.denis-courmont@nokia.com</email>
      </address>
    </author>
    <date year="2008" month="October" day="17" />
    <area>Transport</area>
    <workgroup>Behavior Engineering for Hindrance Avoidance</workgroup>

    <abstract>
      <t> This memo defines a new IPv6 Destination header option
        to convey the transport mapping information
        from an IPv4-IPv4 protocol translator
        to the IPv6 end of a protocol-translated packet flow.
      </t>
    </abstract>
  </front>
  <middle>
    <section title="Introduction">
      <t> To overcome the shortage of IPv4 addresses within the Internet,
        Network Address and Port Translators (NATs) have been widely deployed,
        such that multiple IPv4 nodes can share a single IPv4 address.
        However, that method is known to break certain application protocols,
        which need to know their own assigned external IP address
        and/or port number (i.e. the transport address).
        New solutions are now under consideration which would extend
        NAT mechanisms such that IPv6 nodes could access the IPv4 Internet.
      </t>
      <t> This memo proposes an in-band method for such a IPv6-IPv4 NAT
        to notify affected IPv6 applications of the IPv4 transport address
        associated with any of their active communication flows.
        A new option for the IPv6 Destination extension header,
        the Translated Flow Mapping option
        is hereby defined to carry this information.
      </t>
    </section>

    <section anchor="defs" title="Definitions">
      <t> TBD.
      </t>
      <t> The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
        "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in
        this document are to be interpreted as described in
        <xref target="RFC2119"/>.
      </t>
    </section>

    <section title="IPv4-IPv6 Translation">
      <t> An IPv4-IPv6 NAT performs two separate functions:
        <list style="symbols">
          <t> It receives IPv4 packets on its IPv4 interface,
            translates them to IPv6.
            To that end, for each IPv4 packet,
            it crafts a new IPv6 header to replace the IPv4 header,
            may modify the inner transport protocol header.
            Then, it sends the resulting translated IPv6 packets
            through its IPv6 interface.
          </t>
          <t> Reciprocally, it translates IPv6 packets into IPv4 packets.
          </t>
        </list>
        The details of IPv4-IPv6 translation
        are beyond the scope of this document,
        please refer to [whatever IETF ends up specifying for this] instead.
      </t>
      <section title="Inserting the flow mapping option">
        <t> When a translator receives an IPv4 packet,
          following certain conditions,
          it inserts an IPv6 Destination extension header
          containing a Translated Flow Mapping option
          (as defined in the next section<!-- TODO: ref-->).
        </t>
        <t> As a general rule, this option MUST NOT be inserted,
          if the resulting packet would exceed the known MTU
          to the IPv6 destination, or 1280 bytes if there is no known MTU.
        </t>
        <section title="Usage with connection-oriented protocols">
          <t> For connection-oriented transport protocols,
            this option SHOULD be inserted is part of the protocol
            handshake, and SHOULD NOT be inserted otherwise.
          </t>
          <section title="Datagram Congestion Control Protocol (DCCP)">
            <t> This option SHOULD be inserted within
              DCCP Sync, DCCP Sync/Ack and DCCP Listen packets.
              See <xref target="RFC4340"/>
              and <xref target="I-D.ietf-dccp-simul-open"/>.
            </t>
          </section>
          <section title="Stream Control Transmission Protocol (SCTP)">
            <t> TBD.
            </t>
          </section>
          <section title="Transmission Control Protocol (TCP)">
            <t> This option SHOULD be inserted within
              TCP SYN and TCP SYN/ACK packets.
              See <xref target="RFC0793"/>.
            </t>
          </section>
        </section>
      </section>
      <section title="Receiving the flow mapping option">
        <t> Processing of the flow mapping option is optional.
          In fact, an IPv6 implementation that does not support the
          flow mapping option MUST ignore it, according to
          <xref target="RFC2460"/> (this is not a new requirement
          for IPv6 implementation).
        </t>
        <t> The content of the flow mapping option is merely informational.
          Hence, there are no particular requirements as regards its
          processing.
          An IPv6 stack that implements the flow mapping option MAY
          store and or forward the flow mapping informations, as it sees fit.
          For instance, it might forward the informations to the application
          (see below for an example API) if it requests them.
        </t>
      </section>
    </section>

    <section title="Option format">
      <figure title="Translated Flow Mapping option" align="center">
        <artwork>
0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Option Type  | Option Length |          Mapped Port          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Mapped IPv4 Address                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Remote IPv4 Address                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
          </artwork>
        </figure>
        <t>The Translated Flow Mapping option format is defined as follow:
          <list style="hanging">
            <t hangText="Option Type:">
              XXX (TBD: IANA)
            </t>
            <t hangText="Option Length:">
              12 (12 bytes)
            </t>
            <t hangText="Mapped Port:">
              If the type of the first header that is not an IPv6
              extension header is DCCP, SCTP, TCP, UDP or UDP-Lite,
              the transport protocol mapped port number.
              This is the destination port number found in the original
              IPv4 packet that was translated into the IPv6 packet
              containing this option.
              Otherwise, this must be set to zero by sender,
              and ignored by receivers.
            </t>
            <t hangText="Mapped IPv4 Address:">
              Destination IPv4 address,
              as found in the origin IPv4 packet before translation.
            </t>
            <t hangText="Remote IPv4 Address:">
              Source IPv4 address,
              as found in the origin IPv4 packet before translation.
            </t>
          </list>
        </t>
        <t>The Translated Flow Mapping option requires a 4n alignment
          (as defined per <xref target="RFC2460"/> section 4.2).
        </t>
    </section>

    <section anchor="security" title="Security Considerations">
      <t> TBD.
      </t>
    </section>

    <section anchor="iana" title="IANA Considerations">
      <t> The Translated Flow Mapping option requires an IPv6 Option number.
      </t>
      <t>IPv6 Option Number <xref target="RFC2460"/>:
        <figure>
          <artwork>
HEX         act  chg  rest
---         ---  ---  -----
 XX          00   0   XXXXX     Translated Flow Mapping
          </artwork>
        </figure>
        The first two bits indicate that the IPv6 node may skip
        over this option and continue processing the header
        if it doesn't recognize the option type,
        and the third bit indicates
        that the Option Data may not change en-route.
      </t>
      <t> This document should be listed as the reference document.
      </t>
    </section>

    <appendix title="API Considerations">
      <t> This section is non-normative.
        It defines a potential API to retrieve the flow mapping
        information as an extension to the Advanced IPv6 socket API
        <xref target="RFC3542"/>.
      </t>
      <t> The flow mapping informations shall be passed to applications
        using a structure defined in &lt;netinet/in.h&gt;, and containing
        at least the following fields:
        <figure title="Flow mapping structure">
<artwork>
struct in6_ipv4flowmapping {
  struct uint16_t i4fm6_mapped_port;
  struct in_addr  i4fm6_mapped_addr;
  struct in_addr  i4fm6_remote_addr;
};
</artwork>
        </figure>
      </t>
      <t> For datagram (type SOCK_DGRAM) and raw (type SOCK_RAW) sockets,
        a socket option can configure receiving the flow information
        as ancilliary data on a per-packet basis, using recvmsg.
        This socket option shall be set to 0 (off) by default.
        Setting it to 1 (on) shall enabled flow mapping infos reception.
        Setting it to -1 (default) shall disable it.
        When enabled, an ancilliary data with level IPPROTO_IPV6,
        type IPV6_IPV4FLOWMAPPING shall be returned to the application,
        if a Flow Mapping option was found in the received packet.
        <figure title="Per-packet socket option">
<artwork>
int on = 1;

setsockopt(fd, IPPROTO_IPV6, IPV6_RECVIPV4FLOWMAPPING,
           &amp;yes, sizeof(yes));
</artwork>
        </figure>
      </t>
      <t> For a connected socket, a read-only socket option may be used
        to fetch the flow mapping information if known (i.e. if at least
        one packet with a Flow Mapping Option was received). If unknown,
        the returned structure shall contain all zeroes.
        <figure title="Connected socket option">
<artwork>
struct in6_ipv4flowmapping val;

getsockopt(fd, IPPROTO_IPV6, IPV6_IPV4FLOWMAPPING,
           &amp;val, sizeof(val));
</artwork>
        </figure>
      </t>
    </appendix>

  </middle>
  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.0793" ?>
      <?rfc include="reference.RFC.2119" ?>
      <?rfc include="reference.RFC.2460" ?>
      <?rfc include="reference.RFC.4340" ?>
      <?rfc include="reference.I-D.ietf-dccp-simul-open" ?>
    </references>
    <references title="Informative References">
      <!--?rfc include="reference.RFC.0768" ?-->
      <?rfc include="reference.RFC.3542" ?>
    </references>
  </back>
</rfc>
