source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Dispatcher/tmp/test.cpp @ 32

Last change on this file since 32 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#include <iostream>
2#include <list>
3#include "DispatcherFactory.h"
4#include "SampleData.h"
5
6int main() {
7
8  // Components
9  ComponentId componentA = 111111;
10  ComponentId componentB = 222222;
11
12  std::list<const ComponentId *> components;
13  components.push_back(&componentA);
14  components.push_back(&componentB);
15
16  // Setup Dispatchers (Eth - IP - UDP/TCP automatically set)
17  DispatcherFactory::Instance().Get("UDP")->AddExplicitUpperLayer("DNS"/*, Filter("port", 53) */);
18  DispatcherFactory::Instance().Get("UDP")->AddExplicitUpperLayer("SIP");
19  DispatcherFactory::Instance().Get("TCP")->AddExplicitUpperLayer("SIP");
20
21  // Component A filters
22//   ip.RegisterFilter(&componentA, "addr", "10.0.0.1");
23//   udp.RegisterFilter(&componentA, "port", 5060);
24//   tcp.RegisterFilter(&componentA, "port", 5060);
25//   udp.RegisterFilter(&componentA, "port", 5080);
26//   tcp.RegisterFilter(&componentA, "port", 5080);
27
28  // Component B filters
29//   ip.RegisterFilter(&componentB, "addr", "10.0.0.2");
30//   udp.RegisterFilter(&componentB, "port", 5060);
31//   tdp.RegisterFilter(&componentB, "port", 5060);
32
33
34  // Get root dispatcher
35  Dispatcher *eth = DispatcherFactory::Instance().Get("Ethernet");
36
37  ////////////////////////////////////////////////////////////////
38  // Dispatch DNS Query
39  {
40    std::cout << std::endl << "Dispatch DNS Query" << std::endl;
41
42    DispatchInfo * di = eth->Dispatch(new DispatchInfo(psDnsQuery, 72, components));
43
44    std::cout << "Selected components:" << std::endl;
45    std::list<const ComponentId *>::const_iterator it;   
46    for(it = di->GetComponents().begin();
47        it != di->GetComponents().end();
48        ++it) {
49      std::cout << "---> " << *(*it) << std::endl;
50    }   
51  }
52
53  ////////////////////////////////////////////////////////////////
54  // Dispatch Fragments
55  {
56    std::cout << std::endl << "Dispatch IP fragments" << std::endl;
57
58    eth->Dispatch(new DispatchInfo(psFragmemt_1_1, 1410, components));
59    eth->Dispatch(new DispatchInfo(psFragmemt_1_2, 1410, components));
60    DispatchInfo * di = eth->Dispatch(new DispatchInfo(psFragmemt_1_3, 290, components));
61
62    std::cout << "Selected components:" << std::endl;
63    std::list<const ComponentId *>::const_iterator it;   
64    for(it = di->GetComponents().begin();
65        it != di->GetComponents().end();
66        ++it) {
67      std::cout << "---> " << *(*it) << std::endl;
68    }   
69 
70    // Check that fragments have been correctly reassembled
71    if(memcmp(psPayload_1, di->GetData(), di->GetDataSize())) {
72      std::cout << "OK !" << std::endl;
73    }
74    else {
75      std::cout << "ERROR" << std::endl;
76    }
77  }
78
79  ////////////////////////////////////////////////////////////////
80
81  return 0;
82}
83
Note: See TracBrowser for help on using the repository browser.