src/node/inet6-socket-address.h
author vincent@clarinet.u-strasbg.fr
Fri Nov 07 11:36:15 2008 -0800 (2008-11-07)
changeset 3852 9cf7ad0cac85
child 4761 8c0b3a413f4b
permissions -rw-r--r--
Initial IPv6 capability
vincent@3852
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
vincent@3852
     2
/*
vincent@3852
     3
 * Copyright (c) 2007-2008 Louis Pasteur University
vincent@3852
     4
 *
vincent@3852
     5
 * This program is free software; you can redistribute it and/or modify
vincent@3852
     6
 * it under the terms of the GNU General Public License version 2 as
vincent@3852
     7
 * published by the Free Software Foundation;
vincent@3852
     8
 *
vincent@3852
     9
 * This program is distributed in the hope that it will be useful,
vincent@3852
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
vincent@3852
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
vincent@3852
    12
 * GNU General Public License for more details.
vincent@3852
    13
 *
vincent@3852
    14
 * You should have received a copy of the GNU General Public License
vincent@3852
    15
 * along with this program; if not, write to the Free Software
vincent@3852
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
vincent@3852
    17
 *
vincent@3852
    18
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
vincent@3852
    19
 */
vincent@3852
    20
vincent@3852
    21
#ifndef INET6_SOCKET_ADDRESS_H 
vincent@3852
    22
#define INET6_SOCKET_ADDRESS_H
vincent@3852
    23
vincent@3852
    24
#include "address.h"
vincent@3852
    25
#include "ipv6-address.h"
vincent@3852
    26
#include <stdint.h>
vincent@3852
    27
vincent@3852
    28
namespace ns3 {
vincent@3852
    29
vincent@3852
    30
/**
vincent@3852
    31
 * \class Inet6SocketAddress
vincent@3852
    32
 * \brief An Inet6 address class.
vincent@3852
    33
 */
vincent@3852
    34
class Inet6SocketAddress
vincent@3852
    35
{
vincent@3852
    36
  public:
vincent@3852
    37
    /**
vincent@3852
    38
     * \brief Constructor.
vincent@3852
    39
     * \param ipv6 the IPv6 address
vincent@3852
    40
     * \param port the port
vincent@3852
    41
     */
vincent@3852
    42
    Inet6SocketAddress (Ipv6Address ipv6, uint16_t port);
vincent@3852
    43
vincent@3852
    44
    /**
vincent@3852
    45
     * \brief Constructor (the port is set to zero).
vincent@3852
    46
     * \param ipv6 the IPv6 address
vincent@3852
    47
     */
vincent@3852
    48
    Inet6SocketAddress (Ipv6Address ipv6);
vincent@3852
    49
vincent@3852
    50
    /**
vincent@3852
    51
     * \brief Constructor (the address is set to "any").
vincent@3852
    52
     * \param port the port
vincent@3852
    53
     */
vincent@3852
    54
    Inet6SocketAddress (uint16_t port);
vincent@3852
    55
vincent@3852
    56
    /**
vincent@3852
    57
     * \brief Constructor.
vincent@3852
    58
     * \param ipv6 string which represents an IPv6 address
vincent@3852
    59
     * \param port the port
vincent@3852
    60
     */
vincent@3852
    61
    Inet6SocketAddress (const char* ipv6, uint16_t port);
vincent@3852
    62
vincent@3852
    63
    /**
vincent@3852
    64
     * \brief Constructor.
vincent@3852
    65
     * \param ipv6 string which represents an IPv6 address
vincent@3852
    66
     */
vincent@3852
    67
    Inet6SocketAddress (const char* ipv6);
vincent@3852
    68
vincent@3852
    69
    /**
vincent@3852
    70
     * \brief Get the port.
vincent@3852
    71
     * \return the port
vincent@3852
    72
     */
vincent@3852
    73
    uint16_t GetPort (void) const;
vincent@3852
    74
vincent@3852
    75
    /**
vincent@3852
    76
     * \brief Set the port
vincent@3852
    77
     * \param port the port
vincent@3852
    78
     */
vincent@3852
    79
    void SetPort (uint16_t port);
vincent@3852
    80
vincent@3852
    81
    /**
vincent@3852
    82
     * \brief Get the IPv6 address.
vincent@3852
    83
     * \return the IPv6 address
vincent@3852
    84
     */
vincent@3852
    85
    Ipv6Address GetIpv6 (void) const;
vincent@3852
    86
vincent@3852
    87
    /**
vincent@3852
    88
     * \brief Set the IPv6 address.
vincent@3852
    89
     * \param ipv6 the address
vincent@3852
    90
     */
vincent@3852
    91
    void SetIpv6 (Ipv6Address ipv6);
vincent@3852
    92
vincent@3852
    93
    /**
vincent@3852
    94
     * \brief If the address match.
vincent@3852
    95
     * \param addr the address to test
vincent@3852
    96
     * \return true if the address match, false otherwise
vincent@3852
    97
     */
vincent@3852
    98
    static bool IsMatchingType (const Address &addr);
vincent@3852
    99
vincent@3852
   100
    /**
vincent@3852
   101
     * \brief Get an Address instance which represents this
vincent@3852
   102
     * Inet6SocketAddress instance.
vincent@3852
   103
     */
vincent@3852
   104
    operator Address (void) const;
vincent@3852
   105
vincent@3852
   106
    /**
vincent@3852
   107
     * \brief Convert the address to a InetSocketAddress.
vincent@3852
   108
     * \param addr the address to convert
vincent@3852
   109
     * \return an Inet6SocketAddress instance corresponding to address
vincent@3852
   110
     */
vincent@3852
   111
    static Inet6SocketAddress ConvertFrom (const Address &addr);
vincent@3852
   112
vincent@3852
   113
  private:
vincent@3852
   114
    /**
vincent@3852
   115
     * \brief Convert to Address.
vincent@3852
   116
     * \return Address instance
vincent@3852
   117
     */
vincent@3852
   118
    Address ConvertTo (void) const;
vincent@3852
   119
vincent@3852
   120
    /**
vincent@3852
   121
     * \brief Get the type.
vincent@3852
   122
     * \return the type of Inet6SocketAddress
vincent@3852
   123
     */
vincent@3852
   124
    static uint8_t GetType (void);
vincent@3852
   125
vincent@3852
   126
    /**
vincent@3852
   127
     * \brief The IPv6 address.
vincent@3852
   128
     */
vincent@3852
   129
    Ipv6Address m_ipv6;
vincent@3852
   130
vincent@3852
   131
    /**
vincent@3852
   132
     * \brief The port.
vincent@3852
   133
     */
vincent@3852
   134
    uint16_t m_port;
vincent@3852
   135
};
vincent@3852
   136
vincent@3852
   137
} /* namespace ns3 */
vincent@3852
   138
vincent@3852
   139
#endif /* INET6_SOCKET_ADDRESS_H */
vincent@3852
   140