/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
/*
* Copyright (c) 1997 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#) $Header: /cvsroot/nsnam/ns-2/common/packet.h,v 1.107 2010/05/09 22:28:41 tom_henderson Exp $ (LBL)
*/
#ifndef ns_packet_h
#define ns_packet_h
#include <string.h>
#include <assert.h>
#include "config.h"
#include "scheduler.h"
#include "object.h"
#include "lib/bsd-list.h"
#include "packet-stamp.h"
#include "ns-process.h"
// Used by wireless routing code to attach routing agent
#define RT_PORT 255 /* port that all route msgs are sent to */
#define HDR_CMN(p) (hdr_cmn::access(p))
#define HDR_ARP(p) (hdr_arp::access(p))
#define HDR_MAC(p) (hdr_mac::access(p))
#define HDR_MAC802_11(p) ((hdr_mac802_11 *)hdr_mac::access(p))
#define HDR_MAC_TDMA(p) ((hdr_mac_tdma *)hdr_mac::access(p))
#define HDR_SMAC(p) ((hdr_smac *)hdr_mac::access(p))
#define HDR_LL(p) (hdr_ll::access(p))
#define HDR_HDLC(p) ((hdr_hdlc *)hdr_ll::access(p))
#define HDR_IP(p) (hdr_ip::access(p))
#define HDR_RTP(p) (hdr_rtp::access(p))
#define HDR_TCP(p) (hdr_tcp::access(p))
#define HDR_SCTP(p) (hdr_sctp::access(p))
#define HDR_SR(p) (hdr_sr::access(p))
#define HDR_TFRC(p) (hdr_tfrc::access(p))
#define HDR_TORA(p) (hdr_tora::access(p))
#define HDR_IMEP(p) (hdr_imep::access(p))
#define HDR_CDIFF(p) (hdr_cdiff::access(p)) /* chalermak's diffusion*/
//#define HDR_DIFF(p) (hdr_diff::access(p)) /* SCADD's diffusion ported into ns */
#define HDR_LMS(p) (hdr_lms::access(p))
/* --------------------------------------------------------------------*/
/*
* modified ns-2.33, adding support for dynamic libraries
*
* packet_t is changed from enum to unsigned int in order to allow
* dynamic definition of new packet types within dynamic libraries.
* Pre-defined packet types are implemented as static const.
*
*/
typedef unsigned int packet_t;
static const packet_t PT_TCP = 0;
static const packet_t PT_UDP = 1;
static const packet_t PT_CBR = 2;
static const packet_t PT_AUDIO = 3;
static const packet_t PT_VIDEO = 4;
static const packet_t PT_ACK = 5;
static const packet_t PT_START = 6;
static const packet_t PT_STOP = 7;
static const packet_t PT_PRUNE = 8;
static const packet_t PT_GRAFT = 9;
static const packet_t PT_GRAFTACK = 10;
static const packet_t PT_JOIN = 11;
static const packet_t PT_ASSERT = 12;
static const packet_t PT_MESSAGE = 13;
static const packet_t PT_RTCP = 14;
static const packet_t PT_RTP = 15;
static const packet_t PT_RTPROTO_DV = 16;
static const packet_t PT_CtrMcast_Encap = 17;
static const packet_t PT_CtrMcast_Decap = 18;
static const packet_t PT_SRM = 19;
/* simple signalling messages */
static const packet_t PT_REQUEST = 20;
static const packet_t PT_ACCEPT = 21;
static const packet_t PT_CONFIRM = 22;
static const packet_t PT_TEARDOWN = 23;
static const packet_t PT_LIVE = 24; // packet from live network
static const packet_t PT_REJECT = 25;
static const packet_t PT_TELNET = 26; // not needed: telnet use TCP
static const packet_t PT_FTP = 27;
static const packet_t PT_PARETO = 28;
static const packet_t PT_EXP = 29;
static const packet_t PT_INVAL = 30;
static const packet_t PT_HTTP = 31;
/* new encapsulator */
static const packet_t PT_ENCAPSULATED = 32;
static const packet_t PT_MFTP = 33;
/* CMU/Monarch's extnsions */
static const packet_t PT_ARP = 34;
static const packet_t PT_MAC = 35;
static const packet_t PT_TORA = 36;
static const packet_t PT_DSR = 37;
static const packet_t PT_AODV = 38;
static const packet_t PT_IMEP = 39;
// RAP packets
static const packet_t PT_RAP_DATA = 40;
static const packet_t PT_RAP_ACK = 41;
static const packet_t PT_TFRC = 42;
static const packet_t PT_TFRC_ACK = 43;
static const packet_t PT_PING = 44;
static const packet_t PT_PBC = 45;
// Diffusion packets - Chalermek
static const packet_t PT_DIFF = 46;
// LinkState routing update packets
static const packet_t PT_RTPROTO_LS = 47;
// MPLS LDP header
static const packet_t PT_LDP = 48;
// GAF packet
static const packet_t PT_GAF = 49;
// ReadAudio traffic
static const packet_t PT_REALAUDIO = 50;
// Pushback Messages
static const packet_t PT_PUSHBACK = 51;
#ifdef HAVE_STL
// Pragmatic General Multicast
static const packet_t PT_PGM = 52;
#endif //STL
// LMS packets
static const packet_t PT_LMS = 53;
static const packet_t PT_LMS_SETUP = 54;
static const packet_t PT_SCTP = 55;
static const packet_t PT_SCTP_APP1 = 56;
// SMAC packet
static const packet_t PT_SMAC = 57;
// XCP packet
static const packet_t PT_XCP = 58;
// HDLC packet
static const packet_t PT_HDLC = 59;
// Bell Labs Traffic Trace Type (PackMime OL)
static const packet_t PT_BLTRACE = 60;
// AOMDV packet
static const packet_t PT_AOMDV = 61;
// PUMA packet
static const packet_t PT_PUMA = 62;
// DCCP packets
static const packet_t PT_DCCP = 63;
static const packet_t PT_DCCP_REQ = 64;
static const packet_t PT_DCCP_RESP = 65;
static const packet_t PT_DCCP_ACK = 66;
static const packet_t PT_DCCP_DATA = 67;
static const packet_t PT_DCCP_DATAACK = 68;
static const packet_t PT_DCCP_CLOSE = 69;
static const packet_t PT_DCCP_CLOSEREQ = 70;
static const packet_t PT_DCCP_RESET = 71;
// M-DART packets
static const packet_t PT_MDART = 72;
static const packet_t PT_WFRP = 73;
// insert new packet types here
static packet_t PT_NTYPE = 74; // This MUST be the LAST one
enum packetClass
{
UNCLASSIFIED,
ROUTING,
DATApkt
};
/*
* ns-2.33 adding support for dynamic libraries
*
* The PacketClassifier class is needed to make
* p_info::data_packet(packet_t) work also with dynamically defined
* packet types.
*
*/
class PacketClassifier
{
public:
PacketClassifier(): next_(0){}
virtual ~PacketClassifier() {}
void setNext(PacketClassifier *next){next_ = next;}
PacketClassifier *getNext(){return next_;}
packetClass classify(packet_t type)
{
packetClass c = getClass(type);
if(c == UNCLASSIFIED && next_)
c = next_->classify