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) 1993, 2000 by Sun Microsystems, Inc.
24 * All rights reserved.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include "med_local.h"
30
31 /*
32 * return a response
33 */
34 /*ARGSUSED*/
35 bool_t
med_null_1_svc(void * argp,med_err_t * res,struct svc_req * rqstp)36 med_null_1_svc(
37 void *argp,
38 med_err_t *res,
39 struct svc_req *rqstp /* RPC stuff */
40 )
41 {
42 /* Initialization */
43 *res = med_null_err;
44
45 /* do nothing */
46 return (TRUE);
47 }
48
49 /*
50 * Update the mediator data file.
51 */
52 /*ARGSUSED*/
53 bool_t
med_upd_data_1_svc(med_upd_data_args_t * argp,med_err_t * res,struct svc_req * rqstp)54 med_upd_data_1_svc(
55 med_upd_data_args_t *argp,
56 med_err_t *res,
57 struct svc_req *rqstp /* RPC stuff */
58 )
59 {
60 int err;
61
62 /* Initialization */
63 *res = med_null_err;
64
65 /* setup, check permissions */
66 if ((err = med_init(rqstp, W_OK, res)) < 0)
67 return (FALSE);
68 else if (err != 0)
69 return (TRUE);
70
71 /* doit */
72 if (med_db_init(res))
73 goto out;
74
75 (void) med_db_put_data(&argp->med, &argp->med_data, res);
76
77 out:
78 return (TRUE);
79 }
80
81 /*
82 * Get the mediator data
83 */
84 /*ARGSUSED*/
85 bool_t
med_get_data_1_svc(med_args_t * argp,med_get_data_res_t * res,struct svc_req * rqstp)86 med_get_data_1_svc(
87 med_args_t *argp,
88 med_get_data_res_t *res,
89 struct svc_req *rqstp /* RPC stuff */
90 )
91 {
92 int err;
93 med_data_t *meddp;
94 med_err_t *medep = &res->med_status;
95
96 /* Initialization */
97 (void) memset(res, 0, sizeof (*res));
98 *medep = med_null_err;
99
100 /* setup, check permissions */
101 if ((err = med_init(rqstp, R_OK, medep)) < 0)
102 return (FALSE);
103 else if (err != 0)
104 return (TRUE);
105
106 /* doit */
107 if (med_db_init(medep))
108 goto out;
109
110 if ((meddp = med_db_get_data(&argp->med, medep)) == NULL)
111 goto out;
112
113 res->med_data = *meddp; /* structure assignment */
114
115 out:
116 return (TRUE);
117 }
118
119 /*
120 * Update the mediator record.
121 */
122 /*ARGSUSED*/
123 bool_t
med_upd_rec_1_svc(med_upd_rec_args_t * argp,med_err_t * res,struct svc_req * rqstp)124 med_upd_rec_1_svc(
125 med_upd_rec_args_t *argp,
126 med_err_t *res,
127 struct svc_req *rqstp /* RPC stuff */
128 )
129 {
130 int err;
131
132 /* Initialization */
133 *res = med_null_err;
134
135 /* setup, check permissions */
136 if ((err = med_init(rqstp, W_OK, res)) < 0)
137 return (FALSE);
138 else if (err != 0)
139 return (TRUE);
140
141 /* doit */
142 if (med_db_init(res))
143 goto out;
144
145 (void) med_db_put_rec(&argp->med, &argp->med_rec, res);
146
147 out:
148 return (TRUE);
149 }
150
151 /*
152 * Get the mediator record
153 */
154 /*ARGSUSED*/
155 bool_t
med_get_rec_1_svc(med_args_t * argp,med_get_rec_res_t * res,struct svc_req * rqstp)156 med_get_rec_1_svc(
157 med_args_t *argp,
158 med_get_rec_res_t *res,
159 struct svc_req *rqstp /* RPC stuff */
160 )
161 {
162 med_rec_t *medrp;
163 int err;
164 med_err_t *medep = &res->med_status;
165
166 /* Initialization */
167 (void) memset(res, 0, sizeof (*res));
168 *medep = med_null_err;
169
170 /* setup, check permissions */
171 if ((err = med_init(rqstp, R_OK, medep)) < 0)
172 return (FALSE);
173 else if (err != 0)
174 return (TRUE);
175
176 /* doit */
177 if (med_db_init(medep))
178 goto out;
179
180 if ((medrp = med_db_get_rec(&argp->med, medep)) == NULL)
181 goto out;
182
183 res->med_rec = *medrp; /* structure assignment */
184
185 out:
186 return (TRUE);
187 }
188
189 /*
190 * return the official host name for the callee
191 */
192 /*ARGSUSED*/
193 bool_t
med_hostname_1_svc(void * argp,med_hnm_res_t * res,struct svc_req * rqstp)194 med_hostname_1_svc(
195 void *argp,
196 med_hnm_res_t *res,
197 struct svc_req *rqstp /* RPC stuff */
198 )
199 {
200 med_err_t *medep = &res->med_status;
201 int err;
202
203 /* Initialization */
204 (void) memset(res, 0, sizeof (*res));
205 *medep = med_null_err;
206
207 /* setup, check permissions */
208 if ((err = med_init(rqstp, R_OK, medep)) < 0)
209 return (FALSE);
210 else if (err != 0)
211 return (TRUE);
212
213 /* doit */
214 res->med_hnm = Strdup(mynode());
215
216 return (TRUE);
217 }
218