/* Blinker
Copyright 2011-2014Stefan Schuermans <stefan@blinkenarea.org>
Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
a blinkenarea.org project */
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "Udp6Addr.h"
namespace Blinker {
/// constructor
Udp6Addr::Udp6Addr()
{
m_addr.sin6_family = AF_INET6;
m_addr.sin6_port = htons(0);
inet_pton(AF_INET6, "::", &m_addr.sin6_addr);
}
/// virtual destructor
Udp6Addr::~Udp6Addr()
{
}
/// comparison
//@{
int Udp6Addr::compare(const Udp6Addr &that) const
{
if (m_addr.sin6_family < that.m_addr.sin6_family)
return -1;
if (m_addr.sin6_family > that.m_addr.sin6_family)
return 1;
int cmp = memcmp(&m_addr.sin6_addr, &that.m_addr.sin6_addr,
sizeof(m_addr.sin6_addr));
if (cmp != 0)
return cmp;
if (ntohs(m_addr.sin6_port) < ntohs(that.m_addr.sin6_port))
return -1;
if (ntohs(m_addr.sin6_port) > ntohs(that.m_addr.sin6_port))
return 1;
return 0;
}