Programação de Socket RAW para IPv6

 


Atenção!! Leia a RFC (para trabalho 2)


Partes Importantes (da RFC):


4. MESSAGE FORMATS


4.1. Router Solicitation Message Format


Hosts send Router Solicitations in order to prompt routers to
generate Router Advertisements quickly.


continua na RFC......


6. ROUTER AND PREFIX DISCOVERY


Prefix Discovery is the process through which hosts learn the ranges
of IP addresses that reside on-link and can be reached directly
without going through a router. Routers send Router Advertisements
that indicate whether the sender is willing to be a default router.
Router Advertisements also contain Prefix Information options that
list the set of prefixes that identify on-link IP addresses.

Stateless Address Autoconfiguration must also obtain subnet prefixes
as part of configuring addresses. Although the prefixes used for
address autoconfiguration are logically distinct from those used for
on-link determination, autoconfiguration information is piggybacked
on Router Discovery messages to reduce network traffic. Indeed, the
same prefixes can be advertised for on-link determination and address
autoconfiguration by specifying the appropriate flags in the Prefix
Information options.


6.1.2. Validation of Router Advertisement Messages


A node MUST silently discard any received Router Advertisement
messages that do not satisfy all of the following validity checks:

- IP Source Address is a link-local address. Routers must use
their link-local address as the source for Router Advertisement
and Redirect messages so that hosts can uniquely identify
routers.

- The IP Hop Limit field has a value of 255, i.e., the packet
could not possibly have been forwarded by a router.

- ICMP Checksum is valid.

- ICMP Code is 0.

- ICMP length (derived from the IP length) is 16 or more octets.

- All included options have a length that is greater than zero.

The contents of the Reserved field, and of any unrecognized options,
MUST be ignored. Future, backward-compatible changes to the protocol
may specify the contents of the Reserved field or add new options;
backward-incompatible changes may use different Code values.

The contents of any defined options that are not specified to be used
with Router Advertisement messages MUST be ignored and the packet
processed as normal. The only defined options that may appear are
the Source Link-Layer Address, Prefix Information and MTU options.

An advertisement that passes the validity checks is called a "valid
advertisement".


Materiais de Consulta

    RFC 2133 - Basic Socket Interface Extensions for IPv6
    RFC 2292 - Advanced Sockets API for IPv6
    Porting Applications to IPv6 HowTo

Arquivos do Linux

    /usr/include/linux/ipv6.h
    /usr/include/linux/icmpv6.h
    /usr/include/linux/in6.h
    /usr/include/sys/socket.h
    /usr/include/linux/if_ether.h

Manual on-line do Linux

    comando:      man -7 ipv6

Exemplos de Socket Raw em IPv4
     
                       
    
Exemplo de Socket Raw #1 - Capturando pacotes Ethernet
    Exemplo de Socket Raw #2  - Enviando pacotes Ethernet
          
Trabalho de alunos -  Exemplo #1
                                          Exemplo #2

    Checksum, e outros...

Exemplos de Socket Raw em IPv6

    Lembre-se que as alterações ocorreram no nível 3, o nível ethernet não sofreu alterações.
    Assim, um socket de nível 2 que transporta IPv4 também pode ser usando para transportar
    o protocolo IPv6.

Multicast para ICMP Neighbor Discovery

    O multicast utilizado na descoberta de endereços IPv6 deve ser utilizado da seguinte forma:

        1) o endereço IP é calculado a partir do endereço IPv6 desejado, da seguinte forma:
                Prefixo: FF02:0:0:0:0:1:FF00::/104
                Sufixo: os últimos 24 bits do endereço IPv6

                Exemplo:
                    Endereço  desejado:          3FFF::DEAD::BEEF
                    Multicast ICMP específico: FF02::1:FFAD:BEEF

    A resposta a um Neighbor Discovery segue a mesma regra para a formação de endereços
   de Multicast específico.

    Solicited-Node Address

   

Comandos do linux úteis ao trabalho

    - Mostrando a tabela de IPxMAC do IPv6   

            ip -6 neigh show

    - Adicionado vizinhos na tabela de IPxMAC manualmente

            ip -6 neigh add <ipv6 addr> lladdr <link-layer addr> dev <device>

            exemplo: ip -6 neigh add fec0::1 lladdr 02:01:02:03:04:05 dev eth0

    - Removendo vizinhos na tabela de IPxMAC manualmente

            ip -6 neigh del <ipv6 addr> lladdr <link-layer addr> dev <device>

    - Mostrando a tablea de Roteamento do IPv6

            ip -6 route show

            route -A inet6