ROHC compression/decompression library
ipv6.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991-1997, 2001, 2003, 2006 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017    02110-1301 USA.  */
00018 
00019 /**
00020  * @file   ipv6.h
00021  * @brief  Defines the IPv6 header
00022  * @author Free Software Foundation, Inc
00023  *
00024  * This file contains a part of netinet/ip6.h from the GNU C library. It is
00025  * copied here to be portable on all platforms, even the platforms that miss
00026  * the declarations or got different declarations, such as Microsoft Windows
00027  * or FreeBSD.
00028  */
00029 
00030 #ifndef ROHC_PROTOCOLS_IPV6_H
00031 #define ROHC_PROTOCOLS_IPV6_H
00032 
00033 #include <stdint.h>
00034 
00035 
00036 /**
00037  * @brief The IPv6 address
00038  */
00039 struct ipv6_addr
00040 {
00041         union
00042         {
00043                 uint8_t u8[16];
00044                 uint16_t u16[8];
00045                 uint32_t u32[4];
00046         } addr;
00047 } __attribute__((packed));
00048 
00049 
00050 /**
00051  * @brief The IPv6 header
00052  */
00053 struct ipv6_hdr
00054 {
00055         union
00056         {
00057                 struct ip6_hdrctl
00058                 {
00059                         uint32_t ip6_un1_flow;   /* 4 bits version, 8 bits TC,
00060                                                     20 bits flow-ID */
00061                         uint16_t ip6_un1_plen;   /* payload length */
00062                         uint8_t  ip6_un1_nxt;    /* next header */
00063                         uint8_t  ip6_un1_hlim;   /* hop limit */
00064                 } ip6_un1;
00065                 uint8_t ip6_un2_vfc;       /* 4 bits version, top 4 bits tclass */
00066         } ip6_ctlun;
00067         struct ipv6_addr ip6_src;     /* source address */
00068         struct ipv6_addr ip6_dst;     /* destination address */
00069 } __attribute__((packed));
00070 
00071 #define ip6_vfc   ip6_ctlun.ip6_un2_vfc
00072 #define ip6_flow  ip6_ctlun.ip6_un1.ip6_un1_flow
00073 #define ip6_plen  ip6_ctlun.ip6_un1.ip6_un1_plen
00074 #define ip6_nxt   ip6_ctlun.ip6_un1.ip6_un1_nxt
00075 #define ip6_hlim  ip6_ctlun.ip6_un1.ip6_un1_hlim
00076 #define ip6_hops  ip6_ctlun.ip6_un1.ip6_un1_hlim
00077 
00078 #endif