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
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.
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]
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Implements SLPGetRefreshInterval. This call is an AttrRqst with
31 * the special service type service:directory-agent.sun, sent
32 * only to slpd via loopback, so it mimics the course of a normal
33 * SLPFindAttrs call but reroutes the message to slpd.
40 #include <slp-internal.h>
42 static SLPBoolean
refresh_interval_cb(SLPHandle
, const char *,
45 unsigned short SLPGetRefreshInterval() {
46 slp_handle_impl_t
*hp
; /* SLP handle for this request */
47 SLPError err
; /* any SLPError */
48 char *reply
= NULL
; /* reply from slpd */
49 void *collator
= NULL
; /* attr collation handle */
50 int mr
= 0; /* max results placeholder */
51 unsigned short max
= 0; /* max interval result cookie */
52 char *msg
= NULL
; /* attrrqst msg */
53 char hostname
[MAXHOSTNAMELEN
]; /* name of this host */
55 if ((err
= SLPOpen("en", SLP_FALSE
, (void **)&hp
)) != SLP_OK
) {
56 slp_err(LOG_INFO
, 0, "SLPGetRefreshInterval",
57 "Could not get SLPHandle: %s", slp_strerror(err
));
61 /* tag this as an internal call */
62 hp
->internal_call
= SLP_TRUE
;
64 /* scope is name of this host */
65 (void) gethostname(hostname
, MAXHOSTNAMELEN
);
67 if (slp_packAttrRqst_single(SLP_SUN_DA_TYPE
,
69 "min-refresh-interval",
70 &msg
, "en") != SLP_OK
) {
74 if (slp_send2slpd(msg
, &reply
) != SLP_OK
) {
78 (void) slp_UnpackAttrReply(hp
, reply
, refresh_interval_cb
,
79 &max
, &collator
, &mr
);
81 /* clean up by invoking last call */
82 (void) slp_UnpackAttrReply(hp
, NULL
, refresh_interval_cb
,
83 &max
, &collator
, &mr
);
87 if (reply
) free(reply
);
95 static SLPBoolean
refresh_interval_cb(SLPHandle h
, const char *attrs
,
96 SLPError err
, void *cookie
) {
98 unsigned short *max
= (unsigned short *)cookie
;
104 p
= strchr(attrs
, '=');
109 /* walk through all intervals, looking for the greatest */
110 for (p
++; p
; p
= next
) {
111 unsigned short anint
;
113 next
= strchr(p
, ',');
118 anint
= (unsigned short)atoi(p
);