diff options
author | Salvador Fandino <sfandino@yahoo.com> | 2016-04-20 16:22:56 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-04-27 13:59:34 +0200 |
commit | 3713346f3959782c5e5d1ddd0252f25fb319d732 (patch) | |
tree | a5c9561b419cb278af6f5b27181a5b62496a8f50 /nxcomp/ChannelEndPoint.h | |
parent | b326eda7328e95200f7d70efde35ce51a14bab3d (diff) | |
download | nx-libs-3713346f3959782c5e5d1ddd0252f25fb319d732.tar.gz nx-libs-3713346f3959782c5e5d1ddd0252f25fb319d732.tar.bz2 nx-libs-3713346f3959782c5e5d1ddd0252f25fb319d732.zip |
Provide support for channel endpoints being UNIX file sockets in addition to being TCP/IP sockets.
Diffstat (limited to 'nxcomp/ChannelEndPoint.h')
-rw-r--r-- | nxcomp/ChannelEndPoint.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/nxcomp/ChannelEndPoint.h b/nxcomp/ChannelEndPoint.h new file mode 100644 index 000000000..5b4e75345 --- /dev/null +++ b/nxcomp/ChannelEndPoint.h @@ -0,0 +1,61 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2015 Qindel Formacion y Servicios SL. */ +/* */ +/* This program is free software; you can redistribute it and/or modify */ +/* it under the terms of the GNU General Public License Version 2, as */ +/* published by the Free Software Foundation. */ +/* */ +/* This program is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- */ +/* BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General */ +/* Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public License */ +/* along with this program; if not, you can request a copy to Qindel */ +/* or write to the Free Software Foundation, Inc., 59 Temple Place, Suite */ +/* 330, Boston, MA 02111-1307 USA */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +#ifndef ChannelEndPoint_H +#define ChannelEndPoint_H + +#include <iostream> +#include <sys/un.h> + +class ChannelEndPoint +{ + private: + long defaultTCPPort_; + int defaultTCPInterface_; // 0=localhost, otherwise IP of public interface. + char *defaultUnixPath_; + char *spec_; + + bool specIsPort(long *port = NULL) const; + + public: + ChannelEndPoint(const char *spec = NULL); + ChannelEndPoint &operator=(const ChannelEndPoint &other); + + bool enabled() const; + bool disabled() { return !enabled(); } + void disable(); + void setSpec(const char *spec); + void setSpec(int port); + void setDefaultTCPPort(long port); + void setDefaultTCPInterface(int publicInterface); + void setDefaultUnixPath(char *path); + + bool getUnixPath(char **path = NULL) const; + bool getTCPHostAndPort(char **hostname = NULL, long *port = NULL) const; + long getTCPPort() const; + + bool validateSpec(); +}; + +std::ostream& operator<<(std::ostream& os, const ChannelEndPoint& endPoint); + +#endif |