Changeset 026abfb in rtems-libbsd


Ignore:
Timestamp:
Nov 10, 2014, 7:27:32 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, fd86c091b97759106da7355ce1dd81ebe030e285, freebsd-9.3, f020f08430150c1656a0ad0a1de13699db9b980b
Children:
e6405ea
Parents:
4153ebe
git-author:
Sebastian Huber <sebastian.huber@…> (11/10/14 07:27:32)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/10/14 07:28:38)
Message:

Add rtems_mdns_gethostname()

Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • Makefile

    r4153ebe r026abfb  
    103103LIB_C_FILES += rtemsbsd/ftpd/ftpd.c
    104104LIB_C_FILES += rtemsbsd/mdns/mdns.c
    105 LIB_C_FILES += rtemsbsd/mdns/mdns-sethostname-default.c
     105LIB_C_FILES += rtemsbsd/mdns/mdns-hostname-default.c
    106106LIB_C_FILES += rtemsbsd/pppd/auth.c
    107107LIB_C_FILES += rtemsbsd/pppd/ccp.c
  • freebsd-to-rtems.py

    r4153ebe r026abfb  
    701701                'ftpd/ftpd.c',
    702702                'mdns/mdns.c',
    703                 'mdns/mdns-sethostname-default.c',
     703                'mdns/mdns-hostname-default.c',
    704704                'pppd/auth.c',
    705705                'pppd/ccp.c',
  • rtemsbsd/include/rtems/mdns.h

    r4153ebe r026abfb  
    4242
    4343/* Private variable, do not touch.  Use rtems_mdns_sethostname() instead. */
    44 extern void (*rtems_mdns_sethostname_handler)(const char *hostname);
     44extern int (*rtems_mdns_sethostname_handler)(const char *hostname);
     45
     46/* Private variable, do not touch.  Use rtems_mdns_gethostname() instead. */
     47extern int (*rtems_mdns_gethostname_handler)(char *hostname, size_t size);
    4548
    4649/**
     
    7881 *
    7982 * @param[in] hostname The new multicast hostname.
     83 *
     84 * @retval 0 Successful operation.
     85 * @retval -1 An error occurred.  The errno is set to indicate the error.
    8086 */
    81 static inline void
     87static inline int
    8288rtems_mdns_sethostname(const char *hostname)
    8389{
    84   (*rtems_mdns_sethostname_handler)(hostname);
     90  return (*rtems_mdns_sethostname_handler)(hostname);
     91}
     92
     93/**
     94 * @brief Gets the multicast hostname of the mDNS resolver instance.
     95 *
     96 * @param[in] hostname The multicast hostname buffer.
     97 * @param[in] size The size of the multicast hostname buffer.
     98 *
     99 * @retval 0 Successful operation.
     100 * @retval -1 An error occurred.  The errno is set to indicate the error.
     101 */
     102static inline int
     103rtems_mdns_gethostname(char *hostname, size_t size)
     104{
     105  return (*rtems_mdns_gethostname_handler)(hostname, size);
    85106}
    86107
  • rtemsbsd/mdns/mdns-hostname-default.c

    r4153ebe r026abfb  
    3232#include <rtems/mdns.h>
    3333
    34 static void
     34#include <errno.h>
     35
     36static int
    3537mdns_sethostname_default(const char *hostname)
    3638{
    37         /* Do nothing */
     39  (void)hostname;
     40
     41  errno = ENXIO;
     42
     43  return (-1);
    3844}
    3945
    40 void (*rtems_mdns_sethostname_handler)(const char *hostname) =
     46static int
     47mdns_gethostname_default(char *hostname, size_t size)
     48{
     49  (void)hostname;
     50  (void)size;
     51
     52  errno = ENXIO;
     53
     54  return (-1);
     55}
     56
     57int (*rtems_mdns_sethostname_handler)(const char *hostname) =
    4158    mdns_sethostname_default;
     59
     60int (*rtems_mdns_gethostname_handler)(char *hostname, size_t size) =
     61    mdns_gethostname_default;
  • rtemsbsd/mdns/mdns.c

    r4153ebe r026abfb  
    276276}
    277277
    278 static void
     278static int
    279279mdns_sethostname(const char *hostname)
    280280{
     
    291291
    292292        rtems_bsd_force_select_timeout(mdns_daemon_id);
     293
     294        return (0);
     295}
     296
     297static int
     298mdns_gethostname(char *hostname, size_t size)
     299{
     300        mDNS *m = &mDNSStorage;
     301
     302        if (size < MAX_ESCAPED_DOMAIN_LABEL) {
     303                errno = ERANGE;
     304
     305                return (-1);
     306        }
     307
     308        mDNS_Lock(m);
     309
     310        ConvertDomainLabelToCString(&m->hostlabel, hostname);
     311
     312        mDNS_Unlock(m);
     313
     314        return (0);
    293315}
    294316
     
    344366
    345367        rtems_mdns_sethostname_handler = mdns_sethostname;
     368        rtems_mdns_gethostname_handler = mdns_gethostname;
    346369
    347370        return (RTEMS_SUCCESSFUL);
Note: See TracChangeset for help on using the changeset viewer.