src/node/udp.h
author Craig Dowell
Tue, 27 Mar 2007 15:41:08 -0700
changeset 379 ae74e8a7bb44
parent 345 47b41507a45a
child 453 ddbb935800d8
permissions -rw-r--r--
net device copy and assignment, reference counted channel.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006,2007 INRIA
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 * All rights reserved.
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 * published by the Free Software Foundation;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 * GNU General Public License for more details.
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 */
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#ifndef UDP_H
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#define UDP_H
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include <stdint.h>
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/packet.h"
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    28
#include "ipv4-address.h"
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
#include "ipv4-end-point-demux.h"
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
#include "udp-end-point.h"
295
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    31
#include "ipv4-l4-protocol.h"
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
namespace ns3 {
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    35
class Node;
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 295
diff changeset
    36
class TraceResolver;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 295
diff changeset
    37
class TraceContext;
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    38
295
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    39
class Udp : public Ipv4L4Protocol {
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
public:
295
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    41
  static const uint8_t PROT_NUMBER;
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    42
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    43
  Udp (Node *node);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
  virtual ~Udp ();
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 295
diff changeset
    46
  virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 295
diff changeset
    47
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
  UdpEndPoint *Allocate (void);
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
  UdpEndPoint *Allocate (Ipv4Address address);
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    50
  UdpEndPoint *Allocate (uint16_t port);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
  UdpEndPoint *Allocate (Ipv4Address address, uint16_t port);
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
  UdpEndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
                         Ipv4Address peerAddress, uint16_t peerPort);
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    55
  // called by UdpSocket.
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    56
  void Send (Packet packet,
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    57
             Ipv4Address saddr, Ipv4Address daddr, 
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    58
             uint16_t sport, uint16_t dport);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
  // inherited from Ipv4L4Protocol
295
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    60
  virtual Udp* Copy(Node *node) const;
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    61
  virtual void Receive(Packet& p, 
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    62
                       Ipv4Address const &source,
5fc7ae0d0300 remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    63
                       Ipv4Address const &destination);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
 private:
240
7da682f99bf9 add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    65
  Node *m_node;
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
  Ipv4EndPointDemux<UdpEndPoint> *m_endPoints;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
};
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
}; // namespace ns3
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
#endif /* UDP_H */