Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef __P_UDPCONNECTION_H_
00032 #define __P_UDPCONNECTION_H_
00033 
00034 #include "I_UDPNet.h"
00035 
00036 
00037 class UDPConnectionInternal:public UDPConnection
00038 {
00039 
00040 public:
00041   UDPConnectionInternal();
00042   virtual ~ UDPConnectionInternal();
00043 
00044   Continuation *continuation;
00045   int recvActive;               
00046   int refcount;               
00047 
00048   SOCKET fd;
00049   IpEndpoint binding;
00050   int binding_valid;
00051   int tobedestroyed;
00052   int sendGenerationNum;
00053   int64_t lastSentPktTSSeqNum;
00054 
00055   
00056   
00057   
00058   
00059   
00060   
00061   uint64_t lastSentPktStartTime;
00062   uint64_t lastPktStartTime;
00063 };
00064 
00065 TS_INLINE
00066 UDPConnectionInternal::UDPConnectionInternal()
00067   : continuation(NULL), recvActive(0), refcount(0), fd(-1), binding_valid(0), tobedestroyed(0)
00068 {
00069   sendGenerationNum = 0;
00070   lastSentPktTSSeqNum = -1;
00071   lastSentPktStartTime = 0;
00072   lastPktStartTime = 0;
00073   memset(&binding, 0, sizeof binding);
00074 }
00075 
00076 TS_INLINE
00077 UDPConnectionInternal::~UDPConnectionInternal()
00078 {
00079   continuation = NULL;
00080   mutex = NULL;
00081 }
00082 
00083 
00084 TS_INLINE SOCKET
00085 UDPConnection::getFd()
00086 {
00087   return ((UDPConnectionInternal *) this)->fd;
00088 }
00089 
00090 TS_INLINE void
00091 UDPConnection::setBinding(struct sockaddr const* s)
00092 {
00093   UDPConnectionInternal *p = (UDPConnectionInternal *) this;
00094   ats_ip_copy(&p->binding, s);
00095   p->binding_valid = 1;
00096 }
00097 
00098 TS_INLINE int
00099 UDPConnection::getBinding(struct sockaddr *s)
00100 {
00101   UDPConnectionInternal *p = (UDPConnectionInternal *) this;
00102   ats_ip_copy(s, &p->binding);
00103   return p->binding_valid;
00104 }
00105 
00106 TS_INLINE void
00107 UDPConnection::destroy()
00108 {
00109   ((UDPConnectionInternal *) this)->tobedestroyed = 1;
00110 }
00111 
00112 TS_INLINE int
00113 UDPConnection::shouldDestroy()
00114 {
00115   return ((UDPConnectionInternal *) this)->tobedestroyed;
00116 }
00117 
00118 TS_INLINE void
00119 UDPConnection::AddRef()
00120 {
00121   ink_atomic_increment(&((UDPConnectionInternal *) this)->refcount, 1);
00122 }
00123 
00124 TS_INLINE int
00125 UDPConnection::GetRefCount()
00126 {
00127   return ((UDPConnectionInternal *) this)->refcount;
00128 }
00129 
00130 TS_INLINE int
00131 UDPConnection::GetSendGenerationNumber()
00132 {
00133   return ((UDPConnectionInternal *) this)->sendGenerationNum;
00134 }
00135 
00136 TS_INLINE int
00137 UDPConnection::getPortNum(void)
00138 {
00139   return ats_ip_port_host_order(&static_cast<UDPConnectionInternal *>(this)->binding);
00140 }
00141 
00142 TS_INLINE int64_t
00143 UDPConnection::cancel(void)
00144 {
00145   UDPConnectionInternal *p = (UDPConnectionInternal *) this;
00146 
00147   p->sendGenerationNum++;
00148   p->lastPktStartTime = p->lastSentPktStartTime;
00149   return p->lastSentPktTSSeqNum;
00150 }
00151 
00152 TS_INLINE void
00153 UDPConnection::SetLastSentPktTSSeqNum(int64_t sentSeqNum)
00154 {
00155   ((UDPConnectionInternal *) this)->lastSentPktTSSeqNum = sentSeqNum;
00156 }
00157 
00158 TS_INLINE void
00159 UDPConnection::setContinuation(Continuation * c)
00160 {
00161   
00162   ink_assert(mutex == NULL || c->mutex == mutex);
00163   mutex = c->mutex;
00164   ((UDPConnectionInternal *) this)->continuation = c;
00165 }
00166 
00167 #endif //__P_UDPCONNECTION_H_