Panda3D
|
00001 // Filename: datagramTCPHeader.h 00002 // Created by: drose (08Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef DATAGRAMTCPHEADER_H 00016 #define DATAGRAMTCPHEADER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "netDatagram.h" 00021 00022 #include "datagramIterator.h" 00023 #include "numeric_types.h" 00024 00025 static const int datagram_tcp16_header_size = sizeof(PN_uint16); 00026 static const int datagram_tcp32_header_size = sizeof(PN_uint32); 00027 00028 class NetDatagram; 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : DatagramTCPHeader 00032 // Description : A class that encapsulates the extra bytes that are 00033 // sent in front of each datagram to identify it when it 00034 // is sent on TCP. This is similar to 00035 // DatagramUDPHeader, except it does not include a 00036 // checksum, since this is unnecessary on UDP. 00037 //////////////////////////////////////////////////////////////////// 00038 class EXPCL_PANDA_NET DatagramTCPHeader { 00039 public: 00040 DatagramTCPHeader(const NetDatagram &datagram, int header_size); 00041 DatagramTCPHeader(const void *data, int header_size); 00042 00043 int get_datagram_size(int header_size) const; 00044 INLINE string get_header() const; 00045 00046 bool verify_datagram(const NetDatagram &datagram, int header_size) const; 00047 00048 private: 00049 // The actual data for the header is stored (somewhat recursively) 00050 // in its own NetDatagram object. This is just for convenience of 00051 // packing and unpacking the header. 00052 NetDatagram _header; 00053 }; 00054 00055 #include "datagramTCPHeader.I" 00056 00057 #endif 00058 00059