/* Blinker
Copyright 2011-2019 Stefan 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 <sys/socket.h>
#include <sys/types.h>
#include "Udp4Addr.h"
namespace Blinker {
/// constructor
Udp4Addr::Udp4Addr()
{
m_addr.sin_family = AF_INET;
m_addr.sin_port = htons(0);
m_addr.sin_addr.s_addr = htonl(INADDR_NONE);
}
/// virtual destructor
Udp4Addr::~Udp4Addr()
{
}
/// comparison
//@{
int Udp4Addr::compare(const Udp4Addr &that) const
{
if (m_addr.sin_family < that.m_addr.sin_family)
return -1;
if (m_addr.sin_family > that.m_addr.sin_family)
return 1;
if (ntohl(m_addr.sin_addr.s_addr) < ntohl(that.m_addr.sin_addr.s_addr))
return -1;
if (ntohl(m_addr.sin_addr.s_addr) > ntohl(that.m_addr.sin_addr.s_addr))
return 1;
if (ntohs(m_addr.sin_port) < ntohs(that.m_addr.sin_port))
return -1;
if (ntohs(m_addr.sin_port) > ntohs(that.m_addr.sin_port))
return 1;
return 0;
}
bool Udp4Addr::operator==(const Udp4Addr &that) const