|
a/libupnpp/upnpplib.cxx |
|
b/libupnpp/upnpplib.cxx |
|
... |
|
... |
45 |
|
45 |
|
46 |
LibUPnP *LibUPnP::getLibUPnP(bool server)
|
46 |
LibUPnP *LibUPnP::getLibUPnP(bool server)
|
47 |
{
|
47 |
{
|
48 |
if (theLib == 0)
|
48 |
if (theLib == 0)
|
49 |
theLib = new LibUPnP(server);
|
49 |
theLib = new LibUPnP(server);
|
50 |
if (theLib && !theLib->ok())
|
50 |
if (theLib && !theLib->ok()) {
|
|
|
51 |
delete theLib;
|
|
|
52 |
theLib = 0;
|
51 |
return 0;
|
53 |
return 0;
|
|
|
54 |
}
|
52 |
return theLib;
|
55 |
return theLib;
|
53 |
}
|
56 |
}
|
54 |
|
57 |
|
55 |
|
58 |
|
56 |
LibUPnP::LibUPnP(bool server)
|
59 |
LibUPnP::LibUPnP(bool server)
|
57 |
: m_ok(false)
|
60 |
: m_ok(false)
|
58 |
{
|
61 |
{
|
59 |
m_init_error = UpnpInit(0, 0);
|
62 |
m_init_error = UpnpInit(0, 0);
|
60 |
if (m_init_error != UPNP_E_SUCCESS) {
|
63 |
if (m_init_error != UPNP_E_SUCCESS) {
|
61 |
cerr << errAsString("UpnpInit", m_init_error) << endl;
|
64 |
LOGERR(errAsString("UpnpInit", m_init_error) << endl);
|
62 |
return;
|
65 |
return;
|
63 |
}
|
66 |
}
|
64 |
setMaxContentLength(2000*1024);
|
67 |
setMaxContentLength(2000*1024);
|
65 |
|
68 |
|
66 |
const char *ip_address = UpnpGetServerIpAddress();
|
69 |
const char *ip_address = UpnpGetServerIpAddress();
|
|
... |
|
... |
79 |
m_init_error = UpnpRegisterClient(o_callback, (void *)this, &m_clh);
|
82 |
m_init_error = UpnpRegisterClient(o_callback, (void *)this, &m_clh);
|
80 |
|
83 |
|
81 |
if (m_init_error == UPNP_E_SUCCESS) {
|
84 |
if (m_init_error == UPNP_E_SUCCESS) {
|
82 |
m_ok = true;
|
85 |
m_ok = true;
|
83 |
} else {
|
86 |
} else {
|
84 |
cerr << errAsString("UpnpRegisterClient", m_init_error) << endl;
|
87 |
LOGERR(errAsString("UpnpRegisterClient", m_init_error) << endl);
|
85 |
}
|
88 |
}
|
86 |
}
|
89 |
}
|
87 |
|
90 |
|
88 |
// Servers sometimes make error (e.g.: minidlna returns bad
|
91 |
// Servers sometimes make error (e.g.: minidlna returns bad
|
89 |
// utf-8).
|
92 |
// utf-8).
|
|
... |
|
... |
98 |
description.size(), /* Desc filename len, ignored */
|
101 |
description.size(), /* Desc filename len, ignored */
|
99 |
1, /* URLBase*/
|
102 |
1, /* URLBase*/
|
100 |
o_callback, (void *)this, &m_dvh);
|
103 |
o_callback, (void *)this, &m_dvh);
|
101 |
|
104 |
|
102 |
if (res != UPNP_E_SUCCESS) {
|
105 |
if (res != UPNP_E_SUCCESS) {
|
103 |
cerr << errAsString("UpnpRegisterRootDevice2", m_init_error) << endl;
|
106 |
LOGERR(errAsString("UpnpRegisterRootDevice2", m_init_error) << endl);
|
104 |
}
|
107 |
}
|
105 |
return res;
|
108 |
return res;
|
106 |
}
|
109 |
}
|
107 |
|
110 |
|
108 |
void LibUPnP::setMaxContentLength(int bytes)
|
111 |
void LibUPnP::setMaxContentLength(int bytes)
|
|
... |
|
... |
121 |
#if defined(HAVE_UPNPSETLOGLEVEL)
|
124 |
#if defined(HAVE_UPNPSETLOGLEVEL)
|
122 |
setLogLevel(level);
|
125 |
setLogLevel(level);
|
123 |
UpnpSetLogFileNames(fn.c_str(), fn.c_str());
|
126 |
UpnpSetLogFileNames(fn.c_str(), fn.c_str());
|
124 |
int code = UpnpInitLog();
|
127 |
int code = UpnpInitLog();
|
125 |
if (code != UPNP_E_SUCCESS) {
|
128 |
if (code != UPNP_E_SUCCESS) {
|
126 |
cerr << errAsString("UpnpInitLog", code);
|
129 |
LOGERR(errAsString("UpnpInitLog", code) << endl);
|
127 |
return false;
|
130 |
return false;
|
128 |
}
|
131 |
}
|
129 |
#endif
|
132 |
#endif
|
130 |
}
|
133 |
}
|
131 |
return true;
|
134 |
return true;
|
|
... |
|
... |
202 |
// f81d4fae-7dec-11d0-a765-00a0c91e6bf6
|
205 |
// f81d4fae-7dec-11d0-a765-00a0c91e6bf6
|
203 |
// Where the last 12 chars are provided by the hw addr
|
206 |
// Where the last 12 chars are provided by the hw addr
|
204 |
|
207 |
|
205 |
char hw[20];
|
208 |
char hw[20];
|
206 |
if (getsyshwaddr(hw, 13) < 0) {
|
209 |
if (getsyshwaddr(hw, 13) < 0) {
|
207 |
cerr << "LibUPnP::makeDevUUID: failed retrieving hw addr" << endl;
|
210 |
LOGERR("LibUPnP::makeDevUUID: failed retrieving hw addr" << endl);
|
208 |
strcpy(hw, "2e87682c5ce8");
|
211 |
strcpy(hw, "2e87682c5ce8");
|
209 |
}
|
212 |
}
|
210 |
char uuid[100];
|
213 |
char uuid[100];
|
211 |
sprintf(uuid, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%s",
|
214 |
sprintf(uuid, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%s",
|
212 |
digest[0]&0xff, digest[1]&0xff, digest[2]&0xff, digest[3]&0xff,
|
215 |
digest[0]&0xff, digest[1]&0xff, digest[2]&0xff, digest[3]&0xff,
|