BSDAddressingPolicy.hh
Go to the documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00030 #ifndef HH_SENF_Socket_Protocols_BSDAddressingPolicy_
00031 #define HH_SENF_Socket_Protocols_BSDAddressingPolicy_ 1
00032
00033
00034 #include <senf/Socket/SocketHandle.hh>
00035 #include <senf/Socket/FileHandle.hh>
00036 #include <senf/Socket/CommunicationPolicy.hh>
00037 #include "BSDSocketAddress.hh"
00038
00039
00040
00041
00042 namespace senf {
00043
00045
00046
00051 struct BSDAddressingPolicyMixinBase
00052 {
00053 static void do_local(FileHandle const & handle, struct sockaddr * addr, socklen_t * len);
00054 static void do_peer(FileHandle const & handle, struct sockaddr * addr, socklen_t * len);
00055 static void do_bind(FileHandle const & handle, struct sockaddr const * addr, socklen_t len);
00056 static void do_connect(FileHandle const & handle, struct sockaddr const * addr, socklen_t len);
00057 };
00058
00083 template <class Address>
00084 struct BSDAddressingPolicyMixin
00085 : private BSDAddressingPolicyMixinBase
00086 {
00087 # ifndef DOXYGEN
00088 template <class SPolicy>
00089 static void peer(SocketHandle<SPolicy> const & handle, Address & addr,
00090 typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type * = 0);
00091 # else
00092 template <class SPolicy>
00093 static void peer(SocketHandle<SPolicy> const & handle, Address & addr);
00095
00100 # endif
00101 static void local(FileHandle const & handle, Address & addr);
00103
00106 # ifndef DOXYGEN
00107 template <class SPolicy>
00108 static void connect(SocketHandle<SPolicy> const & handle, Address const & addr,
00109 typename IfCommunicationPolicyIs<SPolicy,ConnectedCommunicationPolicy>::type * = 0);
00110 # else
00111 template <class SPolicy>
00112 static void connect(SocketHandle<SPolicy> const & handle, Address const & addr);
00114
00120 # endif
00121 static void bind(FileHandle const & handle, Address const & addr);
00123
00125 };
00126
00127
00128
00129 struct BSDAddressingPolicy
00130 : public AddressingPolicyBase,
00131 private BSDAddressingPolicyMixin<GenericBSDSocketAddress>
00132 {
00133 typedef GenericBSDSocketAddress Address;
00134
00135 using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::peer;
00136 using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::local;
00137 using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::connect;
00138 using BSDAddressingPolicyMixin<GenericBSDSocketAddress>::bind;
00139 };
00140
00141 }
00142
00143
00144
00145
00146 #include "BSDAddressingPolicy.cti"
00147
00148 #endif
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159