1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright (c) 2000 by Sun Microsystems, Inc.
  24  * All rights reserved.
  25  */
  26 
  27 #ifndef DSVCD_DSVCLOCKD_H
  28 #define DSVCD_DSVCLOCKD_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #include <sys/param.h>
  33 #include <sys/types.h>
  34 
  35 /*
  36  * Data structures and constants that are shared between dsvclockd and
  37  * libdhcpsvc.  This protocol is project-private and is thus subject to
  38  * change at any time.
  39  */
  40 
  41 #ifdef  __cplusplus
  42 extern "C" {
  43 #endif
  44 
  45 #define DSVCD_DOOR_VERSION      1               /* current protocol version */
  46 #define DSVCD_PATH              "/usr/lib/inet/dsvclockd"
  47 #define DSVCD_DOOR_FMT          "/var/run/dsvclockd_%s_door"
  48 
  49 typedef enum { DSVCD_LOCK, DSVCD_UNLOCK } dsvcd_reqtype_t;
  50 typedef enum { DSVCD_NOLOCK, DSVCD_RDLOCK, DSVCD_WRLOCK } dsvcd_locktype_t;
  51 
  52 typedef struct {
  53         uint8_t                 rq_version;     /* version of the API */
  54         dsvcd_reqtype_t         rq_reqtype;     /* request type */
  55 } dsvcd_request_t;
  56 
  57 typedef struct {
  58         uint8_t                 rp_version;     /* version of the API */
  59         int32_t                 rp_retval;      /* DSVC_* return value */
  60 } dsvcd_reply_t;
  61 
  62 typedef struct {
  63         dsvcd_request_t         lrq_request;    /* generic request header */
  64         dsvcd_locktype_t        lrq_locktype;   /* reader or writer */
  65         uint8_t                 lrq_nonblock;   /* cannot block if true */
  66         uint8_t                 lrq_crosshost;  /* do cross-host synch */
  67 
  68         /*
  69          * The caller filling in this request must provide their current
  70          * container version and a name for their container which is
  71          * per-datastore unique (but need not be unique across datastores
  72          * or different versions of the same container.)
  73          *
  74          * The `lrq_loctoken' field must contain a token which "names" a
  75          * given location where the container exists -- note that a given
  76          * location must have exactly one name, though it's permissible for
  77          * more than one location to have the same name (in this case,
  78          * containers from these locations will be synchronized with one
  79          * another, which will hamper performance).  Note that standard
  80          * pathnames do not meet the first constraint (e.g., /var/dhcp and
  81          * /var/../var/dhcp are two different names for the same location),
  82          * but pathnames processed by realpath(3C) do.
  83          *
  84          * If the caller wants cross-host synchronization, then
  85          * `lrq_crosshost' must be set and `lrq_loctoken' must be a
  86          * realpath(3C)'d directory that all hosts can access.
  87          */
  88         int                     lrq_conver;
  89         char                    lrq_conname[64];
  90         char                    lrq_loctoken[MAXPATHLEN];
  91 } dsvcd_lock_request_t;
  92 
  93 typedef struct {
  94         dsvcd_request_t         urq_request;    /* generic request header */
  95 } dsvcd_unlock_request_t;
  96 
  97 #ifdef  __cplusplus
  98 }
  99 #endif
 100 
 101 #endif  /* DSVCD_DSVCLOCKD_H */