Print this page
7388 Support DHCP Client FQDN. Allow IAID/DUID for all v4.


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #ifndef UTIL_H
  26 #define UTIL_H
  27 
  28 #include <sys/types.h>
  29 #include <netinet/in.h>
  30 #include <netinet/dhcp.h>
  31 #include <netinet/dhcp6.h>
  32 #include <libinetutil.h>
  33 #include <dhcpagent_ipc.h>
  34 
  35 #include "common.h"

  36 
  37 /*
  38  * general utility functions which have no better home.  see util.c
  39  * for documentation on how to use the exported functions.
  40  */
  41 
  42 #ifdef  __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 struct dhcp_timer_s {
  47         iu_timer_id_t   dt_id;
  48         lease_t         dt_start;               /* Initial timer value */
  49 };
  50 
  51 /* conversion functions */
  52 const char      *pkt_type_to_string(uchar_t, boolean_t);
  53 const char      *monosec_to_string(monosec_t);
  54 time_t          monosec_to_time(monosec_t);
  55 monosec_t       hrtime_to_monosec(hrtime_t);


  58 void            graceful_shutdown(int);
  59 void            inactivity_shutdown(iu_tq_t *, void *);
  60 
  61 /* timer functions */
  62 void            init_timer(dhcp_timer_t *, lease_t);
  63 boolean_t       cancel_timer(dhcp_timer_t *);
  64 boolean_t       schedule_timer(dhcp_timer_t *, iu_tq_callback_t *, void *);
  65 
  66 /* miscellaneous */
  67 boolean_t       add_default_route(uint32_t, struct in_addr *);
  68 boolean_t       del_default_route(uint32_t, struct in_addr *);
  69 int             daemonize(void);
  70 monosec_t       monosec(void);
  71 void            print_server_msg(dhcp_smach_t *, const char *, uint_t);
  72 boolean_t       bind_sock(int, in_port_t, in_addr_t);
  73 boolean_t       bind_sock_v6(int, in_port_t, const in6_addr_t *);
  74 const char      *iffile_to_hostname(const char *);
  75 int             dhcpv6_status_code(const dhcpv6_option_t *, uint_t,
  76     const char **, const char **, uint_t *);
  77 void            write_lease_to_hostconf(dhcp_smach_t *);


  78 
  79 #ifdef  __cplusplus
  80 }
  81 #endif
  82 
  83 #endif  /* UTIL_H */


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
  24  */
  25 
  26 #ifndef UTIL_H
  27 #define UTIL_H
  28 
  29 #include <sys/types.h>
  30 #include <netinet/in.h>
  31 #include <netinet/dhcp.h>
  32 #include <netinet/dhcp6.h>
  33 #include <libinetutil.h>
  34 #include <dhcpagent_ipc.h>
  35 
  36 #include "common.h"
  37 #include "packet.h"
  38 
  39 /*
  40  * general utility functions which have no better home.  see util.c
  41  * for documentation on how to use the exported functions.
  42  */
  43 
  44 #ifdef  __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 struct dhcp_timer_s {
  49         iu_timer_id_t   dt_id;
  50         lease_t         dt_start;               /* Initial timer value */
  51 };
  52 
  53 /* conversion functions */
  54 const char      *pkt_type_to_string(uchar_t, boolean_t);
  55 const char      *monosec_to_string(monosec_t);
  56 time_t          monosec_to_time(monosec_t);
  57 monosec_t       hrtime_to_monosec(hrtime_t);


  60 void            graceful_shutdown(int);
  61 void            inactivity_shutdown(iu_tq_t *, void *);
  62 
  63 /* timer functions */
  64 void            init_timer(dhcp_timer_t *, lease_t);
  65 boolean_t       cancel_timer(dhcp_timer_t *);
  66 boolean_t       schedule_timer(dhcp_timer_t *, iu_tq_callback_t *, void *);
  67 
  68 /* miscellaneous */
  69 boolean_t       add_default_route(uint32_t, struct in_addr *);
  70 boolean_t       del_default_route(uint32_t, struct in_addr *);
  71 int             daemonize(void);
  72 monosec_t       monosec(void);
  73 void            print_server_msg(dhcp_smach_t *, const char *, uint_t);
  74 boolean_t       bind_sock(int, in_port_t, in_addr_t);
  75 boolean_t       bind_sock_v6(int, in_port_t, const in6_addr_t *);
  76 const char      *iffile_to_hostname(const char *);
  77 int             dhcpv6_status_code(const dhcpv6_option_t *, uint_t,
  78     const char **, const char **, uint_t *);
  79 void            write_lease_to_hostconf(dhcp_smach_t *);
  80 int                     dhcp_add_hostname_opt(dhcp_pkt_t *, dhcp_smach_t *);
  81 int                     dhcp_add_fqdn_opt(dhcp_pkt_t *, dhcp_smach_t *);
  82 
  83 #ifdef  __cplusplus
  84 }
  85 #endif
  86 
  87 #endif  /* UTIL_H */