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 218194 2011-02-02 15:53:09Z 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 *addr, void **ctxp)
61{
62 struct sp_ctx *spctx;
63 int ret;
64
65 if (strcmp(addr, "socketpair://") != 0)
66 return (-1);
67
68 spctx = malloc(sizeof(*spctx));
69 if (spctx == NULL)
70 return (errno);
71
72 if (socketpair(PF_UNIX, SOCK_STREAM, 0, spctx->sp_fd) < 0) {
73 ret = errno;
74 free(spctx);
75 return (ret);
--- 161 unchanged lines hidden ---
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 218194 2011-02-02 15:53:09Z 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 *addr, void **ctxp)
61{
62 struct sp_ctx *spctx;
63 int ret;
64
65 if (strcmp(addr, "socketpair://") != 0)
66 return (-1);
67
68 spctx = malloc(sizeof(*spctx));
69 if (spctx == NULL)
70 return (errno);
71
72 if (socketpair(PF_UNIX, SOCK_STREAM, 0, spctx->sp_fd) < 0) {
73 ret = errno;
74 free(spctx);
75 return (ret);
--- 161 unchanged lines hidden ---