00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef UDP_L4_PROTOCOL_H
00022 #define UDP_L4_PROTOCOL_H
00023
00024 #include <stdint.h>
00025
00026 #include "ns3/packet.h"
00027 #include "ns3/ipv4-address.h"
00028 #include "ns3/ptr.h"
00029 #include "ipv4-end-point-demux.h"
00030 #include "ipv4-l4-protocol.h"
00031
00032 namespace ns3 {
00033
00034 class Node;
00035 class Socket;
00036
00037
00038
00039
00040 class UdpL4Protocol : public Ipv4L4Protocol {
00041 public:
00042 static TypeId GetTypeId (void);
00043 static const uint8_t PROT_NUMBER;
00044
00045 UdpL4Protocol ();
00046 virtual ~UdpL4Protocol ();
00047
00048 void SetNode (Ptr<Node> node);
00049
00050 virtual int GetProtocolNumber (void) const;
00051
00052
00053
00054
00055
00056 Ptr<Socket> CreateSocket (void);
00057
00058 Ipv4EndPoint *Allocate (void);
00059 Ipv4EndPoint *Allocate (Ipv4Address address);
00060 Ipv4EndPoint *Allocate (uint16_t port);
00061 Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
00062 Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
00063 Ipv4Address peerAddress, uint16_t peerPort);
00064
00065 void DeAllocate (Ipv4EndPoint *endPoint);
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 void Send (Ptr<Packet> packet,
00077 Ipv4Address saddr, Ipv4Address daddr,
00078 uint16_t sport, uint16_t dport);
00079
00080
00081
00082
00083
00084
00085
00086
00087 virtual enum Ipv4L4Protocol::RxStatus Receive(Ptr<Packet> p,
00088 Ipv4Address const &source,
00089 Ipv4Address const &destination,
00090 Ptr<Ipv4Interface> interface);
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
00104 uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
00105 Ipv4Address payloadSource,Ipv4Address payloadDestination,
00106 const uint8_t payload[8]);
00107 protected:
00108 virtual void DoDispose (void);
00109 private:
00110 Ptr<Node> m_node;
00111 Ipv4EndPointDemux *m_endPoints;
00112 bool m_calcChecksum;
00113 };
00114
00115 };
00116
00117 #endif