mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-13 19:39:31 +08:00
foobarclient: Use rtems_mdns_initialize()
This commit is contained in:
parent
7ba9b7f24c
commit
c622a5e22a
@ -29,9 +29,6 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mDNSEmbeddedAPI.h>
|
|
||||||
#include <mDNSPosix.h>
|
|
||||||
|
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
@ -46,12 +43,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <rtems.h>
|
||||||
|
#include <rtems/mdns.h>
|
||||||
|
|
||||||
#define TEST_NAME "LIBBSD FOOBAR CLIENT"
|
#define TEST_NAME "LIBBSD FOOBAR CLIENT"
|
||||||
|
|
||||||
static mDNS mDNSStorage;
|
|
||||||
|
|
||||||
static mDNS_PlatformSupport PlatformStorage;
|
|
||||||
|
|
||||||
static CacheEntity rr_cache[64];
|
static CacheEntity rr_cache[64];
|
||||||
|
|
||||||
static const char * const qc_results[] = {
|
static const char * const qc_results[] = {
|
||||||
@ -243,8 +239,8 @@ foobar_register(DNSQuestion *question)
|
|||||||
MakeDomainNameFromDNSNameString(&type, "_foobar._tcp");
|
MakeDomainNameFromDNSNameString(&type, "_foobar._tcp");
|
||||||
MakeDomainNameFromDNSNameString(&domain, "local.");
|
MakeDomainNameFromDNSNameString(&domain, "local.");
|
||||||
|
|
||||||
status = mDNS_StartBrowse(&mDNSStorage, question, &type, &domain,
|
status = mDNS_StartBrowse(rtems_mdns_get_instance(), question, &type,
|
||||||
mDNSNULL, mDNSInterface_Any, 0, mDNSfalse, mDNSfalse,
|
&domain, mDNSNULL, mDNSInterface_Any, 0, mDNSfalse, mDNSfalse,
|
||||||
foobar_browse, NULL);
|
foobar_browse, NULL);
|
||||||
assert(status == mStatus_NoError);
|
assert(status == mStatus_NoError);
|
||||||
}
|
}
|
||||||
@ -254,27 +250,19 @@ test_main(void)
|
|||||||
{
|
{
|
||||||
const char name[] = "foobarclient";
|
const char name[] = "foobarclient";
|
||||||
int rv;
|
int rv;
|
||||||
mStatus status;
|
|
||||||
DNSQuestion question;
|
DNSQuestion question;
|
||||||
|
rtems_status_code sc;
|
||||||
|
|
||||||
rv = sethostname(&name[0], sizeof(name) - 1);
|
rv = sethostname(&name[0], sizeof(name) - 1);
|
||||||
assert(rv == 0);
|
assert(rv == 0);
|
||||||
|
|
||||||
status = mDNS_Init(&mDNSStorage, &PlatformStorage, &rr_cache[0],
|
sc = rtems_mdns_initialize(254, &rr_cache[0], RTEMS_ARRAY_SIZE(rr_cache));
|
||||||
sizeof(rr_cache) / sizeof(rr_cache[0]),
|
assert(sc == RTEMS_SUCCESSFUL);
|
||||||
mDNS_Init_AdvertiseLocalAddresses, mDNS_Init_NoInitCallback,
|
|
||||||
mDNS_Init_NoInitCallbackContext);
|
|
||||||
assert(status == mStatus_NoError);
|
|
||||||
|
|
||||||
foobar_register(&question);
|
foobar_register(&question);
|
||||||
|
|
||||||
while (1) {
|
rtems_task_delete(RTEMS_SELF);
|
||||||
struct timeval timeout = { .tv_sec = 0x3fffffff, .tv_usec = 0 };
|
assert(0);
|
||||||
sigset_t signals;
|
|
||||||
mDNSBool got_something;
|
|
||||||
|
|
||||||
mDNSPosixRunEventLoopOnce(&mDNSStorage, &timeout, &signals, &got_something);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFAULT_NETWORK_DHCPCD_ENABLE
|
#define DEFAULT_NETWORK_DHCPCD_ENABLE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user