00001 /** @file 00002 00003 A brief file description 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 */ 00023 00024 /**************************************************************************** 00025 00026 I_UDPPacket.h 00027 UDPPacket interface 00028 00029 00030 ****************************************************************************/ 00031 00032 #ifndef __I_UDPPACKET_H_ 00033 #define __I_UDPPACKET_H_ 00034 00035 #include "I_UDPConnection.h" 00036 /** @name UDPPacket 00037 UDP packet functions used by UDPConnection 00038 */ 00039 //@{ 00040 /** 00041 UDP data with destination 00042 */ 00043 class UDPPacket 00044 { 00045 00046 public: 00047 00048 virtual ~UDPPacket() 00049 { } 00050 00051 virtual void free(); // fast deallocate 00052 void setContinuation(Continuation * c); 00053 void setConnection(UDPConnection * c); 00054 UDPConnection *getConnection(); 00055 IOBufferBlock *getIOBlockChain(); 00056 int64_t getPktLength(); 00057 00058 /** 00059 Add IOBufferBlock (chain) to end of packet. 00060 @param block block chain to add. 00061 00062 */ 00063 inkcoreapi void append_block(IOBufferBlock * block); 00064 00065 IpEndpoint from; // what address came from 00066 IpEndpoint to; // what address to send to 00067 00068 int from_size; 00069 00070 LINK(UDPPacket, link); 00071 }; 00072 00073 /** 00074 Create a new packet to be sent over UDPConnection. This actually 00075 copies data from a buffer. 00076 00077 00078 @param to address of where to send packet 00079 @param when ink_hrtime relative to ink_get_hrtime_internal() 00080 @param buf if !NULL, then len bytes copied from buf and made into packet. 00081 @param len # of bytes to copy from buf 00082 */ 00083 extern UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0, char *buf = NULL, int len = 0); 00084 /** 00085 Create a new packet to be sent over UDPConnection. This clones and 00086 makes a reference to an existing IOBufferBlock chain. 00087 00088 00089 @param to address of where to send packet 00090 @param when ink_hrtime relative to ink_get_hrtime_internal() 00091 @param block if !NULL, then the IOBufferBlock chain of data to use 00092 for packet 00093 @param len # of bytes to reference from block 00094 */ 00095 00096 TS_INLINE UDPPacket *new_UDPPacket(struct sockaddr const* to, ink_hrtime when = 0, 00097 IOBufferBlock * block = NULL, int len = 0); 00098 /** 00099 Create a new packet to be sent over UDPConnection. Packet has no 00100 destination or data. 00101 */ 00102 extern UDPPacket *new_UDPPacket(); 00103 00104 /** 00105 Create a new packet to be delivered to application. 00106 Internal function only 00107 */ 00108 extern UDPPacket *new_incoming_UDPPacket(struct sockaddr* from, char *buf, int len); 00109 00110 //@} 00111 #endif //__I_UDPPACKET_H_