View previous topic :: View next topic |
Author |
Message |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Fri Jan 01, 2021 8:37 am Post subject: MiniSSDPd: register / submit service |
|
|
I want to submit a service to minissdpd so that minissdpd advertises my service on my LAN.
I'm assuming I must use "request type 4 = submit service". Correct?
testminissdpd.c uses this command: 'char command4[] = "\x04\x00test:test:test";'
Is that the command I should use to submit a service? Is the ":" the separator ... ?
If so, in what format? Looking at other existing devices/messages, my first guess would be
char command4[] = "\x04\x00http://192.168.2.222:22222/IGD.xml:urn:dslforum-org:device:WANConnectionDevice:1:uuid:11111111-405a-3721-e8b8-20e882bf0aa1::urn:dslforum-org:device:WANConnectionDevice:1" ;
... but because there are multiple :'s I can't imagine this works. And indeed it does not work: it does not show up in the list reported my testminisspd
I think the answer is in the documentation, but I don't understand it:
request type 4 = submit service
1st byte = 4
(k,n) bytes : length and string "ST" (service type)
(k,n) bytes : length and string "USN"
(k,n) bytes : length and string "Server"
(k,n) bytes : length and string "Location"
I would appreciate to know the correct format for command4[].
Last edited by superkoning on Fri Jan 01, 2021 8:38 am; edited 1 time in total |
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Fri Jan 01, 2021 8:38 am Post subject: |
|
|
FWIW I tried this format too, but doesn't work either.
char command4[] = "\x04\x00uuid:44444444-b051-11db-88f8-0060085db3f6::upnp:rootdevice" ;
FWIW 2
I tried to understand
http://miniupnp.free.fr/minissdpd.html
UPnP Device submit (request type 4)
These "request" type is used by UPnP devices that declare themselves and their services that way. The first byte is 4 and is followed by four Strings :
Service/device type
USN
Server string (as found in SSDP packets)
Location
There is no response.
and
https://github.com/miniupnp/miniupnp/tree/master/minissdpd
request type 4 = submit service
1st byte = 4
(k,n) bytes : length and string "ST" (service type)
(k,n) bytes : length and string "USN"
(k,n) bytes : length and string "Server"
(k,n) bytes : length and string "Location"
No answer
... but no luck |
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Sun Jan 03, 2021 7:06 am Post subject: |
|
|
Further tries:
char command4[] = "\x04\x05PQRST\x05PQRST\x05PQRST\x05PQRST" ;
char command4[] = "\x04\x00\x05PQRST\x05PQRST\x05PQRST\x05PQRST" ;
... but no luck.
Help appreciated. |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1594
|
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1594
|
Posted: Wed Jan 06, 2021 7:31 pm Post subject: |
|
|
ST is a string such as urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN uuid:73616d61-6a6b-7a74-650a-0d24d4a5d636::urn:schemas-upnp-org:device:InternetGatewayDevice:1
SERVER My Software/0.1
LOCATION http://192.168.0.1:12345/rootDesc.xml
_________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1594
|
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Wed Jan 06, 2021 10:27 pm Post subject: |
|
|
OK, thanks ... 30 lines of C code ... with some coffee I must be able to understand that. |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1594
|
Posted: Thu Jan 07, 2021 9:01 am Post subject: |
|
|
superkoning wrote: |
OK, thanks ... 30 lines of C code ... with some coffee I must be able to understand that. |
You don't need to understand fully to just copy paste
I think I will add sample.c file so people can include in their software and not worry about. _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Thu Jan 07, 2021 10:18 am Post subject: |
|
|
miniupnp wrote: | superkoning wrote: |
OK, thanks ... 30 lines of C code ... with some coffee I must be able to understand that. |
You don't need to understand fully to just copy paste
I think I will add sample.c file so people can include in their software and not worry about. |
Well, my goal is to register my service to minissdpd from ... pyhon. So I must understand the c code to write python code ...  |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1594
|
Posted: Thu Jan 07, 2021 1:00 pm Post subject: |
|
|
ok i should try to write it in python3  _________________ Main miniUPnP author.
https://miniupnp.tuxfamily.org/ |
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Thu Jan 07, 2021 2:08 pm Post subject: |
|
|
miniupnp wrote: | ok i should try to write it in python3  |
That would be fantastic. Indeed python3 (python2 is EoL). |
|
Back to top |
|
 |
miniupnp Site Admin
Joined: 14 Apr 2007 Posts: 1594
|
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Thu Jan 07, 2021 7:56 pm Post subject: |
|
|
miniupnp wrote: | https://github.com/miniupnp/miniupnp/blob/master/minissdpd/submit_to_minissdpd.py |
Wow, that is fast!
Let's check:
Code: | $ cat submit_to_minissdpd.py | tail -1 | tr "," "\n"
SubmitServicesToMiniSSDPD(b'urn:schemas-upnp-org:device:InternetGatewayDevice:1'
b'uuid:73616d61-6a6b-7a74-650a-0d24d4a5d636::urn:schemas-upnp-org:device:InternetGatewayDevice:1'
b'MyServer/0.0'
b'http://192.168.0.1:1234/rootDesc.xml')
|
After
Code: | python3 submit_to_minissdpd.py |
./testminissdpd reveals:
Code: | 23 - http://192.168.0.1:1234/rootDesc.xml
urn:schemas-upnp-org:device:InternetGatewayDevice:1
uuid:73616d61-6a6b-7a74-650a-0d24d4a5d636::urn:schemas-upnp-org:device:InternetGatewayDevice:1 |
Looks good!
I don't see the b'MyServer/0.0 part in the output of testminisspdpd ... I guess that is by design?
Cool! Thank you.
EDIT:
One remark:
Code: | #!/usr/bin/env python |
That does not work on Ubuntu 20.04: 'python' refers to python2, which is not installed on Ubuntu 20.04
For python3 scripts, it's adviced to use
Code: | #!/usr/bin/env python3 |
Reason: 'python' is ambigous, and often pointing to python2 (because of legacy). So therefore 'python3' in the shebang. |
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Thu Jan 07, 2021 8:21 pm Post subject: |
|
|
I'll send my suggestions via a PR |
|
Back to top |
|
 |
superkoning
Joined: 01 Jan 2021 Posts: 14 Location: ::1
|
Posted: Fri Jan 08, 2021 12:56 pm Post subject: |
|
|
superkoning wrote: | I'll send my suggestions via a PR |
PR sent: https://github.com/miniupnp/miniupnp/pull/520
Now usable as stand-alone program, and module.
Code: | Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import submit_to_minissdpd
>>> submit_to_minissdpd.codelength(b"blalbla")
b'\x07blalbla'
>>> submit_to_minissdpd.codelength("blalbla")
b'\x07blalbla'
>>> submit_to_minissdpd.codelength("你好")
b'\x00'
>>> submit_to_minissdpd.submit_to_minissdpd("line 1", "line 2", "line 3", "line 4")
(0, 'OK') |
|
|
Back to top |
|
 |
|