Changeset 7a3fe8e in rtems-libbsd for rtemsbsd/mdns


Ignore:
Timestamp:
11/06/14 07:28:06 (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
Children:
0bed8d9
Parents:
50e82a6
git-author:
Sebastian Huber <sebastian.huber@…> (11/06/14 07:28:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/06/14 07:29:57)
Message:

Add rtems_mdns_sethostname()

Use it to set the multi-cast hostname of the default mDNS resolver
instance via sethostname().

Location:
rtemsbsd/mdns
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/mdns/mdns.c

    r50e82a6 r7a3fe8e  
    3232#include <mDNSEmbeddedAPI.h>
    3333#include <mDNSPosix.h>
     34#include <DNSCommon.h>
    3435
    3536#include <sys/select.h>
     
    5556#include <rtems/mdns.h>
    5657
    57 static rtems_id daemon_id;
     58static rtems_id mdns_daemon_id;
    5859
    5960static mDNS mDNSStorage;
     
    224225
    225226        mDNS_StartQuery(&mDNSStorage, &q);
    226         rtems_bsd_force_select_timeout(daemon_id);
     227        rtems_bsd_force_select_timeout(mdns_daemon_id);
    227228
    228229        sc = rtems_event_transient_receive(RTEMS_WAIT,
     
    262263}
    263264
     265static void
     266truncate_at_first_dot(domainlabel *name)
     267{
     268        int c = name->c[0];
     269        int n = 0;
     270
     271        while (n < c && name->c[n + 1] != '.') {
     272                ++n;
     273        }
     274
     275        name->c[0] = n;
     276}
     277
     278static void
     279mdns_sethostname(const char *hostname)
     280{
     281        mDNS *m = &mDNSStorage;
     282
     283        mDNS_Lock(m);
     284
     285        MakeDomainLabelFromLiteralString(&m->hostlabel, hostname);
     286        truncate_at_first_dot(&m->hostlabel);
     287
     288        mDNS_Unlock(m);
     289
     290        mDNS_SetFQDN(m);
     291
     292        rtems_bsd_force_select_timeout(mdns_daemon_id);
     293}
     294
    264295rtems_status_code
    265296rtems_mdns_initialize(rtems_task_priority daemon_priority,
     
    280311        sc = rtems_task_create(rtems_build_name('m', 'D', 'N', 'S'),
    281312            daemon_priority, 16 * 1024, RTEMS_DEFAULT_MODES,
    282             RTEMS_DEFAULT_ATTRIBUTES, &daemon_id);
     313            RTEMS_DEFAULT_ATTRIBUTES, &mdns_daemon_id);
    283314        if (sc != RTEMS_SUCCESSFUL) {
    284315                return (RTEMS_UNSATISFIED);
    285316        }
    286317
    287         sc = rtems_task_start(daemon_id, mdns_daemon, 0);
     318        sc = rtems_task_start(mdns_daemon_id, mdns_daemon, 0);
    288319        if (sc != RTEMS_SUCCESSFUL) {
    289320                return (RTEMS_UNSATISFIED);
     
    312343        }
    313344
     345        rtems_mdns_sethostname_handler = mdns_sethostname;
     346
    314347        return (RTEMS_SUCCESSFUL);
    315348}
Note: See TracChangeset for help on using the changeset viewer.