]> git.llucax.com Git - software/posixx.git/blob - test/linux/tipc/common.hpp
Initial import of the POSIX thin wrapper for C++
[software/posixx.git] / test / linux / tipc / common.hpp
1 #ifndef TEST_LINUX_TIPC_COMMON_HPP_
2 #define TEST_LINUX_TIPC_COMMON_HPP_
3
4 #include <posixx/linux/tipc.hpp> // posixx::linux::tipc
5 #include <ostream> // std::ostream
6
7 #define PTYPE 10000
8 #define INST1 10001
9 #define INST2 10002
10
11 static inline
12 std::ostream& operator << (std::ostream& os,
13                 const posixx::linux::tipc::sockaddr& sa) throw()
14 {
15         using posixx::linux::tipc::sockaddr;
16         os << "tipc::sockaddr(scope=" << unsigned(sa.scope) << ", ";
17         switch (sa.type())
18         {
19         case sockaddr::ID:
20                 os << "id(ref=" << sa.addr.id.ref
21                                 << ", node=" << sa.addr.id.node << ")";
22                 break;
23         case sockaddr::NAME:
24                 os << "name(type=" << sa.addr.name.name.type
25                                 << ", instance=" << sa.addr.name.name.instance
26                                 << ", domain=" << sa.addr.name.domain << ")";
27                 break;
28         case sockaddr::NAMESEQ:
29                 os << "nameseq(type=" << sa.addr.nameseq.type
30                                 << ", lower=" << sa.addr.nameseq.lower
31                                 << ", upper=" << sa.addr.nameseq.upper << ")";
32                 break;
33         default:
34                 os << "UNKNOWN!";
35         }
36         return os << ")";
37 }
38
39 // no need to clean addresses
40 #define clean_test_address(socket, addr)
41
42 static posixx::linux::tipc::sockaddr test_address1(
43                 posixx::linux::tipc::name(PTYPE, INST1));
44 static posixx::linux::tipc::sockaddr test_address2(
45                 posixx::linux::tipc::name(PTYPE, INST2));
46
47 #endif // TEST_LINUX_TIPC_COMMON_HPP_