root/plugin/ipc/socket/connectionrewirer.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /****************************************************************************
   2  *   Copyright (C) 2006-2008 by Jason Ansel, Kapil Arya, and Gene Cooperman *
   3  *   jansel@csail.mit.edu, kapil@ccs.neu.edu, gene@ccs.neu.edu              *
   4  *                                                                          *
   5  *   This file is part of the dmtcp/src module of DMTCP (DMTCP:dmtcp/src).  *
   6  *                                                                          *
   7  *  DMTCP:dmtcp/src is free software: you can redistribute it and/or        *
   8  *  modify it under the terms of the GNU Lesser General Public License as   *
   9  *  published by the Free Software Foundation, either version 3 of the      *
  10  *  License, or (at your option) any later version.                         *
  11  *                                                                          *
  12  *  DMTCP:dmtcp/src is distributed in the hope that it will be useful,      *
  13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
  14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
  15  *  GNU Lesser General Public License for more details.                     *
  16  *                                                                          *
  17  *  You should have received a copy of the GNU Lesser General Public        *
  18  *  License along with DMTCP:dmtcp/src.  If not, see                        *
  19  *  <http://www.gnu.org/licenses/>.                                         *
  20  ****************************************************************************/
  21 
  22 #pragma once
  23 #ifndef CONNECTIONREWIRER_H
  24 #define CONNECTIONREWIRER_H
  25 
  26 #include <sys/socket.h>
  27 #include <sys/un.h>
  28 #include "dmtcpalloc.h"
  29 #include "connectionidentifier.h"
  30 #include "connection.h"
  31 
  32 namespace dmtcp
  33 {
  34   typedef map<ConnectionIdentifier, Connection*> ConnectionListT;
  35 
  36   class ConnectionRewirer
  37   {
  38     public:
  39       struct RemoteAddr {
  40         struct sockaddr_storage addr;
  41         socklen_t len;
  42         Connection *con;
  43       };
  44 
  45       static ConnectionRewirer& instance();
  46       static void destroy();
  47 
  48       void openRestoreSocket(bool hasIPv4, bool hasIPv6, bool hasUNIX);
  49       void registerIncoming(const ConnectionIdentifier& local,
  50                             Connection *con,
  51                             int domain);
  52       void registerOutgoing(const ConnectionIdentifier& remote,
  53                             Connection *con);
  54       void registerNSData();
  55       void sendQueries();
  56       void doReconnect();
  57       void checkForPendingIncoming(int restoreSockFd, ConnectionListT *conList);
  58 
  59       void debugPrint() const;
  60 
  61     private:
  62       void registerNSData(void *addr, socklen_t len, ConnectionListT *conList);
  63 
  64       struct sockaddr_in    _ip4RestoreAddr;
  65       socklen_t             _ip4RestoreAddrlen;
  66       struct sockaddr_in6   _ip6RestoreAddr;
  67       socklen_t             _ip6RestoreAddrlen;
  68       struct sockaddr_un    _udsRestoreAddr;
  69       socklen_t             _udsRestoreAddrlen;
  70 
  71       typedef ConnectionListT::iterator iterator;
  72       typedef ConnectionListT::const_iterator const_iterator;
  73       typedef map<ConnectionIdentifier, struct RemoteAddr> RemoteInfoT;
  74       typedef RemoteInfoT::iterator remoteInfoIter;
  75 
  76       ConnectionListT _pendingIP4Incoming;
  77       ConnectionListT _pendingIP6Incoming;
  78       ConnectionListT _pendingUDSIncoming;
  79 
  80       ConnectionListT _pendingOutgoing;
  81       RemoteInfoT     _remoteInfo;
  82   };
  83 
  84 }
  85 
  86 #endif

/* [<][>][^][v][top][bottom][index][help] */