Deleted Added
full compact
proto_uds.c (218193) proto_uds.c (218194)
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sbin/hastd/proto_uds.c 218193 2011-02-02 15:46:28Z pjd $");
31__FBSDID("$FreeBSD: head/sbin/hastd/proto_uds.c 218194 2011-02-02 15:53:09Z pjd $");
32
33/* UDS - UNIX Domain Socket */
34
35#include <sys/un.h>
36
37#include <errno.h>
38#include <stdbool.h>
39#include <stdint.h>

--- 172 unchanged lines hidden (view full) ---

212 newuctx->uc_side = UDS_SIDE_SERVER_WORK;
213 newuctx->uc_magic = UDS_CTX_MAGIC;
214 *newctxp = newuctx;
215
216 return (0);
217}
218
219static int
32
33/* UDS - UNIX Domain Socket */
34
35#include <sys/un.h>
36
37#include <errno.h>
38#include <stdbool.h>
39#include <stdint.h>

--- 172 unchanged lines hidden (view full) ---

212 newuctx->uc_side = UDS_SIDE_SERVER_WORK;
213 newuctx->uc_magic = UDS_CTX_MAGIC;
214 *newctxp = newuctx;
215
216 return (0);
217}
218
219static int
220uds_send(void *ctx, const unsigned char *data, size_t size)
220uds_send(void *ctx, const unsigned char *data, size_t size, int fd)
221{
222 struct uds_ctx *uctx = ctx;
223
224 PJDLOG_ASSERT(uctx != NULL);
225 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
226 PJDLOG_ASSERT(uctx->uc_fd >= 0);
227
221{
222 struct uds_ctx *uctx = ctx;
223
224 PJDLOG_ASSERT(uctx != NULL);
225 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
226 PJDLOG_ASSERT(uctx->uc_fd >= 0);
227
228 return (proto_common_send(uctx->uc_fd, data, size));
228 return (proto_common_send(uctx->uc_fd, data, size, fd));
229}
230
231static int
229}
230
231static int
232uds_recv(void *ctx, unsigned char *data, size_t size)
232uds_recv(void *ctx, unsigned char *data, size_t size, int *fdp)
233{
234 struct uds_ctx *uctx = ctx;
235
236 PJDLOG_ASSERT(uctx != NULL);
237 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
238 PJDLOG_ASSERT(uctx->uc_fd >= 0);
239
233{
234 struct uds_ctx *uctx = ctx;
235
236 PJDLOG_ASSERT(uctx != NULL);
237 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
238 PJDLOG_ASSERT(uctx->uc_fd >= 0);
239
240 return (proto_common_recv(uctx->uc_fd, data, size));
240 return (proto_common_recv(uctx->uc_fd, data, size, fdp));
241}
242
243static int
241}
242
243static int
244uds_descriptor_send(void *ctx, int fd)
245{
246 struct uds_ctx *uctx = ctx;
247
248 PJDLOG_ASSERT(uctx != NULL);
249 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
250 PJDLOG_ASSERT(uctx->uc_fd >= 0);
251 PJDLOG_ASSERT(fd >= 0);
252
253 return (proto_common_descriptor_send(uctx->uc_fd, fd));
254}
255
256static int
257uds_descriptor_recv(void *ctx, int *fdp)
258{
259 struct uds_ctx *uctx = ctx;
260
261 PJDLOG_ASSERT(uctx != NULL);
262 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
263 PJDLOG_ASSERT(uctx->uc_fd >= 0);
264 PJDLOG_ASSERT(fdp != NULL);
265
266 return (proto_common_descriptor_recv(uctx->uc_fd, fdp));
267}
268
269static int
270uds_descriptor(const void *ctx)
271{
272 const struct uds_ctx *uctx = ctx;
273
274 PJDLOG_ASSERT(uctx != NULL);
275 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
276
277 return (uctx->uc_fd);

--- 66 unchanged lines hidden (view full) ---

344 .hp_name = "uds",
345 .hp_client = uds_client,
346 .hp_connect = uds_connect,
347 .hp_connect_wait = uds_connect_wait,
348 .hp_server = uds_server,
349 .hp_accept = uds_accept,
350 .hp_send = uds_send,
351 .hp_recv = uds_recv,
244uds_descriptor(const void *ctx)
245{
246 const struct uds_ctx *uctx = ctx;
247
248 PJDLOG_ASSERT(uctx != NULL);
249 PJDLOG_ASSERT(uctx->uc_magic == UDS_CTX_MAGIC);
250
251 return (uctx->uc_fd);

--- 66 unchanged lines hidden (view full) ---

318 .hp_name = "uds",
319 .hp_client = uds_client,
320 .hp_connect = uds_connect,
321 .hp_connect_wait = uds_connect_wait,
322 .hp_server = uds_server,
323 .hp_accept = uds_accept,
324 .hp_send = uds_send,
325 .hp_recv = uds_recv,
352 .hp_descriptor_send = uds_descriptor_send,
353 .hp_descriptor_recv = uds_descriptor_recv,
354 .hp_descriptor = uds_descriptor,
355 .hp_local_address = uds_local_address,
356 .hp_remote_address = uds_remote_address,
357 .hp_close = uds_close
358};
359
360static __constructor void
361uds_ctor(void)
362{
363
364 proto_register(&uds_proto, false);
365}
326 .hp_descriptor = uds_descriptor,
327 .hp_local_address = uds_local_address,
328 .hp_remote_address = uds_remote_address,
329 .hp_close = uds_close
330};
331
332static __constructor void
333uds_ctor(void)
334{
335
336 proto_register(&uds_proto, false);
337}