1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3
* Copyright (c) 2009 INRIA, UDcast
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
22
#include "ipcs-classifier.h"
25
#include "service-flow.h"
26
#include "ns3/packet.h"
27
#include "ns3/ipv4-header.h"
28
#include "ns3/udp-header.h"
29
#include "ns3/tcp-header.h"
30
#include "ns3/llc-snap-header.h"
31
#include "ns3/udp-l4-protocol.h"
32
#include "ns3/tcp-l4-protocol.h"
34
NS_LOG_COMPONENT_DEFINE ("IpcsClassifier");
38
IpcsClassifier::IpcsClassifier (void)
42
IpcsClassifier::~IpcsClassifier (void)
47
IpcsClassifier::Classify (Ptr<const Packet> packet,
48
Ptr<ServiceFlowManager> sfm, ServiceFlow::Direction dir)
50
Ptr<Packet> C_Packet = packet->Copy ();
53
C_Packet->RemoveHeader (llc);
55
Ipv4Header ipv4Header;
56
C_Packet->RemoveHeader (ipv4Header);
57
Ipv4Address source_address = ipv4Header.GetSource ();
58
Ipv4Address dest_address = ipv4Header.GetDestination ();
59
uint8_t protocol = ipv4Header.GetProtocol ();
61
uint16_t sourcePort = 0;
62
uint16_t destPort = 0;
63
if (protocol == UdpL4Protocol::PROT_NUMBER)
66
C_Packet->RemoveHeader (udpHeader);
67
sourcePort = udpHeader.GetSourcePort ();
68
destPort = udpHeader.GetDestinationPort ();
70
else if (protocol == TcpL4Protocol::PROT_NUMBER)
73
C_Packet->RemoveHeader (tcpHeader);
74
sourcePort = tcpHeader.GetSourcePort ();
75
destPort = tcpHeader.GetDestinationPort ();
79
NS_LOG_INFO ("\t\t\tUnknown protocol: " << protocol);
83
NS_LOG_INFO ("Classifing packet: src_addr=" << source_address << " dst_addr="
84
<< dest_address << " src_port=" << sourcePort << " dst_port="
85
<< destPort << " proto=" << (uint16_t) protocol);
86
return (sfm->DoClassify (source_address,