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_socketpair.c 219818 2011-03-21 08:54:59Z pjd $"); |
32 33#include <sys/types.h> 34#include <sys/socket.h> 35 36#include <errno.h> 37#include <stdbool.h> 38#include <stdint.h> 39#include <stdio.h> --- 12 unchanged lines hidden (view full) --- 52#define SP_SIDE_UNDEF 0 53#define SP_SIDE_CLIENT 1 54#define SP_SIDE_SERVER 2 55}; 56 57static void sp_close(void *ctx); 58 59static int |
60sp_client(const char *srcaddr, const char *dstaddr, void **ctxp) |
61{ 62 struct sp_ctx *spctx; 63 int ret; 64 |
65 if (strcmp(dstaddr, "socketpair://") != 0) |
66 return (-1); 67 |
68 PJDLOG_ASSERT(srcaddr == NULL); 69 |
70 spctx = malloc(sizeof(*spctx)); 71 if (spctx == NULL) 72 return (errno); 73 74 if (socketpair(PF_UNIX, SOCK_STREAM, 0, spctx->sp_fd) < 0) { 75 ret = errno; 76 free(spctx); 77 return (ret); --- 161 unchanged lines hidden --- |