~ubuntu-branches/ubuntu/quantal/ns3/quantal

« back to all changes in this revision

Viewing changes to ns-3.12.1/src/wimax/model/ipcs-classifier.cc

  • Committer: Package Import Robot
  • Author(s): YunQiang Su, Aron Xu, YunQiang Su, Upstream
  • Date: 2012-01-06 00:35:42 UTC
  • mfrom: (10.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120106003542-vcn5g03mhapm991h
Tags: 3.13+dfsg-1
[ Aron Xu ]:
        add tag binary and binary-indep, 
  for not build doc when --binary-arch (Closes: #654493).
[ YunQiang Su ]
        add waf 1.5/1.6 source to debian directory, 
  and build waf from there (Closes: #642217).
[ Upstream ]
  Successfully link with --as-needed option (Closes: #642225).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
 
/*
3
 
 *  Copyright (c) 2009 INRIA, UDcast
4
 
 *
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;
8
 
 *
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.
13
 
 *
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
17
 
 *
18
 
 *         Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19
 
 *
20
 
 */
21
 
 
22
 
#include "ipcs-classifier.h"
23
 
#include <stdint.h>
24
 
#include "ns3/log.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"
33
 
 
34
 
NS_LOG_COMPONENT_DEFINE ("IpcsClassifier");
35
 
 
36
 
namespace ns3 {
37
 
 
38
 
IpcsClassifier::IpcsClassifier (void)
39
 
{
40
 
}
41
 
 
42
 
IpcsClassifier::~IpcsClassifier (void)
43
 
{
44
 
}
45
 
 
46
 
ServiceFlow *
47
 
IpcsClassifier::Classify (Ptr<const Packet> packet,
48
 
                          Ptr<ServiceFlowManager> sfm, ServiceFlow::Direction dir)
49
 
{
50
 
  Ptr<Packet> C_Packet = packet->Copy ();
51
 
 
52
 
  LlcSnapHeader llc;
53
 
  C_Packet->RemoveHeader (llc);
54
 
 
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 ();
60
 
 
61
 
  uint16_t sourcePort = 0;
62
 
  uint16_t destPort = 0;
63
 
  if (protocol == UdpL4Protocol::PROT_NUMBER)
64
 
    {
65
 
      UdpHeader udpHeader;
66
 
      C_Packet->RemoveHeader (udpHeader);
67
 
      sourcePort = udpHeader.GetSourcePort ();
68
 
      destPort = udpHeader.GetDestinationPort ();
69
 
    }
70
 
  else if (protocol == TcpL4Protocol::PROT_NUMBER)
71
 
    {
72
 
      TcpHeader tcpHeader;
73
 
      C_Packet->RemoveHeader (tcpHeader);
74
 
      sourcePort = tcpHeader.GetSourcePort ();
75
 
      destPort = tcpHeader.GetDestinationPort ();
76
 
    }
77
 
  else
78
 
    {
79
 
      NS_LOG_INFO ("\t\t\tUnknown protocol: " << protocol);
80
 
      return 0;
81
 
    }
82
 
 
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,
87
 
                           dest_address,
88
 
                           sourcePort,
89
 
                           destPort,
90
 
                           protocol,dir));
91
 
}
92
 
 
93
 
}