light weight SSDP library
The Simple Service Discovery Protocol (SSDP) is a network protocol based on the Internet Protocol Suite for advertisement and discovery of network services and presence information.
lssdp has been forked from https://github.com/zlargon/lssdp, released under the MIT license. Modification to the forked code are copyright 2017 Commend International GmbH and the respecitve authors, and released under MIT license.
====
- Linux Ubuntu
- MAC OSX
- Android
- iOS
A C/C++ compiler supporting C99/C++11 is required, tested with GCC 5.4.
The libraries provided by the following Ubuntu packages must be installed: libncurses5-dev, libtinfo-dev, libgpm-dev.
====
make clean
make
cd test
./client.exe
./service.exe <identification_id>
Client lists all services and removes stopped services.
====
lssdp context
port - SSDP UDP port, 1900 port is general.
sock - SSDP socket, created by lssdp_socket_create
, and close by lssdp_socket_close
debug - SSDP debug mode, show debug message.
header.search_target - SSDP Search Target (ST). A potential search target.
header.unique_service_name - SSDP Unique Service Name (USN). A composite identifier for the advertisement.
header.location = prefix + domain + suffix - [http://] + IP + [:PORT/URI]
header.sm_id - Optional field.
header.device_type - Optional field.
network_interface_changed_callback - when interface is changed, this callback would be invoked.
neighbor_list_changed_callback - when neighbor list is changed, this callback would be invoked.
packet_received_callback - when received any SSDP packet, this callback would be invoked. It callback is usally used for debugging.
====
create SSDP socket.
- SSDP port must be setup ready before call this function. (lssdp.port > 0)
- if SSDP socket is already exist (lssdp.sock > 0), the socket will be closed, and create a new one.
- SSDP neighbor list will be force clean up.
close SSDP socket.
- if SSDP socket <= 0, will be ignore, and lssdp.sock will be set -1.
- SSDP neighbor list will be force clean up.
read SSDP socket.
1. if read success, packet_received_callback will be invoked.
2. if received SSDP packet is match to Search Target (lssdp.header.search_target),
- M-SEARCH: send RESPONSE back
- NOTIFY/RESPONSE: add/update to SSDP neighbor list
- SSDP socket and port must be setup ready before call this function. (sock, port > 0)
- if SSDP neighbor list has been changed, neighbor_list_changed_callback will be invoked.
send SSDP M-SEARCH packet to multicast address
- SSDP port must be setup ready before call this function. (lssdp.port > 0)
send SSDP NOTIFY packet to multicast address
- SSDP port must be setup ready before call this function. (lssdp.port > 0)
setup SSDP log callback. All SSDP library log will be forward to here.