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_UDPConnection.h 00027 UDPConnection interface 00028 00029 00030 ****************************************************************************/ 00031 00032 #ifndef __I_UDPCONNECTION_H_ 00033 #define __I_UDPCONNECTION_H_ 00034 00035 #include "I_EventSystem.h" 00036 #define INK_ETHERNET_MTU_SIZE 1472 00037 class UDPPacket; 00038 /** 00039 UDP Connection endpoint 00040 00041 You can schedule packet to be sent immediately or for the future, 00042 and set up a persistent receive() operation. 00043 */ 00044 00045 class UDPConnection:public Continuation 00046 { 00047 public: 00048 virtual ~ UDPConnection() 00049 { 00050 }; 00051 00052 SOCKET getFd(); 00053 void setBinding(struct sockaddr const *); 00054 inkcoreapi int getBinding(struct sockaddr *); 00055 00056 void destroy(); 00057 int shouldDestroy(); 00058 /** 00059 <p> 00060 <b>Callbacks:</b><br> 00061 cont->handleEvent(NET_EVENT_DATAGRAM_WRITE_ERROR, UDPPacket *) on error 00062 <br> 00063 no callback on success. 00064 00065 @return Action* send can't be cancelled via this Action 00066 @param c continuation to be called back 00067 @param p packet to be sent. 00068 */ 00069 Action *send(Continuation * c, UDPPacket * p); 00070 00071 /** 00072 <p> 00073 <b>Callbacks:</b><br> 00074 cont->handleEvent(NET_EVENT_DATAGRAM_ERROR, UDPConnection *) on error 00075 <br> 00076 cont->handleEvent(NET_EVENT_DATAGRAM_READ_READY, Queue<UDPPacketInternal> *) on incoming packets. 00077 00078 @return Action* Always returns ACTION_RESULT_NONE. Can't be 00079 cancelled via this Action. 00080 @param c continuation to be called back 00081 */ 00082 Action *recv(Continuation * c); 00083 00084 void Release(); 00085 void AddRef(); 00086 int GetRefCount(); 00087 00088 int getPortNum(void); 00089 00090 int GetSendGenerationNumber(); //const 00091 void SetLastSentPktTSSeqNum(int64_t sentSeqNum); 00092 int64_t cancel(); 00093 void setContinuation(Continuation * c); 00094 00095 /** 00096 Put socket on net queue for read/write polling. 00097 00098 Not required for UDPConnections created with UDPNetProcessor::UDPBind 00099 00100 Required for and UDPNetProcessor::CreateUDPSocket. They don't do 00101 bindToThread() automatically so that the sockets can be passed to 00102 other Continuations. 00103 */ 00104 void bindToThread(Continuation * c); 00105 00106 virtual void UDPConnection_is_abstract() = 0; 00107 }; 00108 00109 extern UDPConnection *new_UDPConnection(int fd); 00110 #endif //__I_UDPCONNECTION_H_