forked from openhome/ohNetmon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathohNetworkMonitor.cpp
More file actions
117 lines (85 loc) · 2.7 KB
/
Copy pathohNetworkMonitor.cpp
File metadata and controls
117 lines (85 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <OpenHome/OhNetTypes.h>
#include <OpenHome/Net/Core/DvDevice.h>
#include <OpenHome/Net/Core/OhNet.h>
#include <OpenHome/Net/Core/CpDevice.h>
#include <OpenHome/Net/Core/CpDeviceUpnp.h>
#include <OpenHome/Private/Ascii.h>
#include <OpenHome/Private/Maths.h>
#include <OpenHome/Net/Private/Stack.h>
#include <OpenHome/Private/Thread.h>
#include <OpenHome/Private/OptionParser.h>
#include <OpenHome/Private/Debug.h>
#include <vector>
#include <stdio.h>
#include "NetworkMonitor.h"
#ifdef _WIN32
#pragma warning(disable:4355) // use of 'this' in ctor lists safe in this case
#define CDECL __cdecl
#include <conio.h>
int mygetch()
{
return (_getch());
}
#else
#define CDECL
#include <termios.h>
#include <unistd.h>
int mygetch()
{
struct termios oldt, newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}
#endif
using namespace OpenHome;
using namespace OpenHome::Net;
using namespace OpenHome::TestFramework;
int CDECL main(int aArgc, char* aArgv[])
{
OptionParser parser;
OptionString optionName("-n", "--name", Brx::Empty(), "[name] name of the NetworkMonitor");
parser.AddOption(&optionName);
if (!parser.Parse(aArgc, aArgv)) {
return (1);
}
if (optionName.Value().Bytes() == 0) {
printf("Name not specified\n");
return (1);
}
InitialisationParams* initParams = InitialisationParams::Create();
UpnpLibrary::Initialise(initParams);
UpnpLibrary::StartDv();
Bws<100> udn("OpenHome-NetworkMonitor-");
udn.Append(optionName.Value());
DvDeviceStandard* device = new DvDeviceStandard(udn);
device->SetAttribute("Upnp.Domain", "av.openhome.org");
device->SetAttribute("Upnp.Type", "Sender");
device->SetAttribute("Upnp.Version", "1");
device->SetAttribute("Upnp.FriendlyName", (const TChar*)udn.PtrZ());
device->SetAttribute("Upnp.Manufacturer", "Openhome");
device->SetAttribute("Upnp.ManufacturerUrl", "http://www.openhome.org");
device->SetAttribute("Upnp.ModelDescription", "Openhome Network Monitor");
device->SetAttribute("Upnp.ModelName", "Openhome Network Monitor");
device->SetAttribute("Upnp.ModelNumber", "1");
device->SetAttribute("Upnp.ModelUrl", "http://www.openhome.org");
device->SetAttribute("Upnp.SerialNumber", "");
device->SetAttribute("Upnp.Upc", "");
NetworkMonitor* nm = new NetworkMonitor(*device, optionName.Value());
device->SetEnabled();
for (;;) {
int key = mygetch();
if (key == 'q') {
break;
}
}
delete (nm);
delete (device);
printf("\n");
return (0);
}