/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2005 INRIA * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation; * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Mathieu Lacage */ #include #include "arp-header.h" #include "header-utils.h" namespace ns3 { ArpHeader::~ArpHeader () {} void ArpHeader::SetRequest (MacAddress sourceHardwareAddress, Ipv4Address sourceProtocolAddress, MacAddress destinationHardwareAddress, Ipv4Address destinationProtocolAddress) { m_type = ARP_TYPE_REQUEST; m_macSource = sourceHardwareAddress; m_macDest = destinationHardwareAddress; m_ipv4Source = sourceProtocolAddress; m_ipv4Dest = destinationProtocolAddress; } void ArpHeader::SetReply (MacAddress sourceHardwareAddress, Ipv4Address sourceProtocolAddress, MacAddress destinationHardwareAddress, Ipv4Address destinationProtocolAddress) { m_type = ARP_TYPE_REPLY; m_macSource = sourceHardwareAddress; m_macDest = destinationHardwareAddress; m_ipv4Source = sourceProtocolAddress; m_ipv4Dest = destinationProtocolAddress; } bool ArpHeader::IsRequest (void) const { return (m_type == ARP_TYPE_REQUEST)?true:false; } bool ArpHeader::IsReply (void) const { return (m_type == ARP_TYPE_REPLY)?true:false; } MacAddress ArpHeader::GetSourceHardwareAddress (void) { return m_macSource; } MacAddress ArpHeader::GetDestinationHardwareAddress (void) { return m_macDest; } Ipv4Address ArpHeader::GetSourceIpv4Address (void) { return m_ipv4Source; } Ipv4Address ArpHeader::GetDestinationIpv4Address (void) { return m_ipv4Dest; } void ArpHeader::PrintTo (std::ostream &os) const { os << "(arp)"; if (IsRequest ()) { os << " source mac: " << m_macSource << " source ipv4: " << m_ipv4Source << " dest ipv4: " << m_ipv4Dest; } else { assert (IsReply ()); os << " source mac: " << m_macSource << " source ipv4: " << m_ipv4Source << " dest mac: " << m_macDest << " dest ipv4: " <