1 /* $Id: testssdppktgen.c,v 1.1 2015/10/26 16:54:31 nanard Exp $ */
7 #include "miniupnpdpath.h"
11 #define SSDP_PORT 1900
13 char uuidvalue_igd
[] = "uuid:12345678-0000-0000-0000-000000abcd01";
15 unsigned upnp_configid
;
18 MakeSSDPPacket(const char * dest_str
,
19 const char * host
, unsigned short http_port
,
21 unsigned short https_port
,
23 const char * nt
, const char * suffix
,
24 const char * usn1
, const char * usn2
, const char * usn3
,
25 unsigned int lifetime
)
27 char bufr
[SSDP_PACKET_MAX_LEN
];
30 l
= snprintf(bufr
, sizeof(bufr
),
31 "NOTIFY * HTTP/1.1\r\n"
33 "CACHE-CONTROL: max-age=%u\r\n"
34 "LOCATION: http://%s:%u" ROOTDESC_PATH
"\r\n"
36 "SECURELOCATION.UPNP.ORG: https://%s:%u" ROOTDESC_PATH
"\r\n"
38 "SERVER: " MINIUPNPD_SERVER_STRING
"\r\n"
42 "OPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n" /* UDA v1.1 */
43 "01-NLS: %u\r\n" /* same as BOOTID field. UDA v1.1 */
44 "BOOTID.UPNP.ORG: %u\r\n" /* UDA v1.1 */
45 "CONFIGID.UPNP.ORG: %u\r\n" /* UDA v1.1 */
47 dest_str
, SSDP_PORT
, /* HOST: */
48 lifetime
, /* CACHE-CONTROL: */
49 host
, (unsigned int)http_port
, /* LOCATION: */
51 host
, (unsigned int)https_port
, /* SECURE-LOCATION: */
54 usn1
, usn2
, usn3
, suffix
, /* USN: */
55 upnp_bootid
, /* 01-NLS: */
56 upnp_bootid
, /* BOOTID.UPNP.ORG: */
57 upnp_configid
); /* CONFIGID.UPNP.ORG: */
59 syslog(LOG_ERR
, "%s: snprintf error", "MakeSSDPPacket()");
61 } else if((unsigned int)l
>= sizeof(bufr
)) {
62 syslog(LOG_WARNING
, "%s: truncated output (%u>=%u)",
63 "MakeSSDPPacket()", (unsigned)l
, (unsigned)sizeof(bufr
));
71 int main(int argc
, char * * argv
)
74 UNUSED(argc
); UNUSED(argv
);
76 openlog("testssdppktgen", LOG_CONS
|LOG_PERROR
, LOG_USER
);
77 upnp_bootid
= (unsigned)time(NULL
);
78 upnp_configid
= 1234567890;
79 r
= MakeSSDPPacket("123.456.789.123", "222.222.222.222", 12345,
82 #endif /* ENABLE_HTTPS */
83 "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:", "1",
84 uuidvalue_igd
, "", "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:",
88 r
= MakeSSDPPacket("[1234:5678:abcd:ef00:1234:5678:abcd:ef00]",
89 "[1000:2000:3000:4000:5000:6000:7000:8000]", 12345,
92 #endif /* ENABLE_HTTPS */
93 "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:", "1",
94 uuidvalue_igd
, "", "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:",
97 #endif /* ENABLE_IPV6 */