source: source/ariba/utility/addressing/test_addressing.hpp@ 12772

Last change on this file since 12772 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 2.3 KB
RevLine 
[5284]1#ifndef TEST_ADDRESSING_HPP_
2#define TEST_ADDRESSING_HPP_
3
4#include "addressing.hpp"
5
6namespace ariba {
7namespace addressing {
8namespace detail {
9
10using namespace ariba::addressing;
11
12void test() {
13
14 mac_address mac("01:02:03:04:05:06");
15 port_address port("12345");
16 ip_address ipv4("127.0.0.1");
17 ip_address ipv6("::127.0.0.1");
18
19 tcpip_endpoint tcpip;
20 tcpip = "10.11.12.13:5001";
21 cout << tcpip.to_string() << endl;
22 tcpip = "[::10.11.12.13]:5001";
23 cout << tcpip.to_string() << endl;
24
25 address_vf addr_mac = mac;
26 address_vf addr_port = port;
27 to_string_vf addr_to_string = ipv4;
28
29 cout << addr_to_string->to_string() << endl;
30 cout << addr_mac->clone()->to_string() << endl;
31 cout << (*addr_mac == *addr_mac) << endl;
32
33 uint8_t bytes[80];
34
35 tcpip.to_bytes(bytes);
36 for (size_t i=0; i<tcpip.to_bytes_size(); i++) printf("%02X",bytes[i]);
37 printf("\n");
38 tcpip = "10.11.12.13:5001";
39 tcpip.assign( bytes, 18 );
40 cout << tcpip.to_string() << endl;
41
42 cout << "Testing endpoint_set: " << endl;
43 cout << "-> to_string methods:" << endl;
44 string set_test = "tcp{5001 | 5002};ip{::10.11.12.13 | 127.0.0.1};bluetooth{01:02:03:04:05:06};rfcomm{10 | 11 | 12 | 13};";
45 endpoint_set set = set_test;
46 cout << " * This = " << set.to_string() << endl;
47 cout << " * That = " << set_test << endl;
48 cout << " * Ok = " << (set.to_string().size() == set_test.size()) << endl;
49 cout << "-> to_bytes methods:" << endl;
50 uint8_t* set_bytes = new uint8_t[set.to_bytes_size()];
51 set.to_bytes(set_bytes);
52 endpoint_set new_set(set_bytes, set.to_bytes_size());
53 cout << " * Bin = ";
54 for (size_t i=0; i<set.to_bytes_size(); i++) printf("%02X",set_bytes[i]);
55 cout << endl;
56 cout << " * This = " << set.to_string() << endl;
57 cout << " * That = " << new_set.to_string() << endl;
58 cout << " * Ok = " << (set.to_string().size() == new_set.to_string().size()) << endl;
59
60/*
61 tcpip_endpoint tcp("10.11.12.13", "1234");
62 endpoint_vf endp_tcp = tcp;
63 *endp_tcp->get(0) = "::12.13.14.15";
64
65 cout << endp_tcp->get(0)->to_string() << endl;
66 cout << tcp.address().to_string() << endl;
67
68 cout << endp_tcp->to_string() << endl;
69
70// *addr_mac = "0a:0b:0c:0d:0e:0f";
71
72 cout << mac.to_string() << endl;
73 cout << addr_mac->clone() << endl;
74 cout << addr_port->clone() << endl;
75 cout << (*addr_mac == *addr_mac) << endl;
76*/
77}
78
79}}} // namespace ariba::addressing::detail
80
81#endif /* TEST_ADDRESSING_HPP_ */
Note: See TracBrowser for help on using the repository browser.