• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

P_UnixUDPConnection.h

Go to the documentation of this file.
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   P_UnixUDPConnection.h
00027   Unix UDPConnection implementation
00028 
00029 
00030  ****************************************************************************/
00031 #ifndef __UNIXUDPCONNECTION_H_
00032 #define __UNIXUDPCONNECTION_H_
00033 
00034 #include "P_UDPConnection.h"
00035 #include "P_UDPPacket.h"
00036 
00037 class UnixUDPConnection:public UDPConnectionInternal
00038 {
00039 public:
00040   void init(int the_fd);
00041   void setEthread(EThread * e);
00042   void errorAndDie(int e);
00043   int callbackHandler(int event, void *data);
00044 
00045   LINK(UnixUDPConnection, polling_link);
00046   LINK(UnixUDPConnection, callback_link);
00047   SLINK(UnixUDPConnection, newconn_alink);
00048 
00049   InkAtomicList inQueue;
00050   int onCallbackQueue;
00051   Action *callbackAction;
00052   EThread *ethread;
00053   EventIO ep;
00054 
00055   UnixUDPConnection(int the_fd);
00056   virtual ~ UnixUDPConnection();
00057 private:
00058   int m_errno;
00059   virtual void UDPConnection_is_abstract() {};
00060 };
00061 
00062 TS_INLINE
00063 UnixUDPConnection::UnixUDPConnection(int the_fd)
00064   : onCallbackQueue(0)
00065   , callbackAction(NULL)
00066   , ethread(NULL)
00067   , m_errno(0)
00068 {
00069   fd = the_fd;
00070   UDPPacketInternal p;
00071   ink_atomiclist_init(&inQueue, "Incoming UDP Packet queue", (char *) &p.alink.next - (char *) &p);
00072   SET_HANDLER(&UnixUDPConnection::callbackHandler);
00073 }
00074 
00075 TS_INLINE void
00076 UnixUDPConnection::init(int the_fd)
00077 {
00078   fd = the_fd;
00079   onCallbackQueue = 0;
00080   callbackAction = NULL;
00081   ethread = NULL;
00082   m_errno = 0;
00083 
00084   UDPPacketInternal p;
00085   ink_atomiclist_init(&inQueue, "Incoming UDP Packet queue", (char *) &p.alink.next - (char *) &p);
00086   SET_HANDLER(&UnixUDPConnection::callbackHandler);
00087 }
00088 
00089 TS_INLINE void
00090 UnixUDPConnection::setEthread(EThread * e)
00091 {
00092   ethread = e;
00093 }
00094 
00095 TS_INLINE void
00096 UnixUDPConnection::errorAndDie(int e)
00097 {
00098   m_errno = e;
00099 }
00100 
00101 TS_INLINE Action *
00102 UDPConnection::recv(Continuation * c)
00103 {
00104   UnixUDPConnection *p = (UnixUDPConnection *) this;
00105   // register callback interest.
00106   p->continuation = c;
00107   ink_assert(c != NULL);
00108   mutex = c->mutex;
00109   p->recvActive = 1;
00110   return ACTION_RESULT_NONE;
00111 }
00112 
00113 
00114 TS_INLINE UDPConnection *
00115 new_UDPConnection(int fd)
00116 {
00117   return (fd >= 0) ? new UnixUDPConnection(fd) : 0;
00118 }
00119 
00120 #endif //__UNIXUDPCONNECTION_H_

Generated by  doxygen 1.7.1