1d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan/*
2d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * dhcpcd - DHCP client daemon
3d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
4d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * All rights reserved
5d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
6d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * Redistribution and use in source and binary forms, with or without
7d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * modification, are permitted provided that the following conditions
8d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * are met:
9d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * 1. Redistributions of source code must retain the above copyright
10d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan *    notice, this list of conditions and the following disclaimer.
11d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * 2. Redistributions in binary form must reproduce the above copyright
12d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan *    notice, this list of conditions and the following disclaimer in the
13d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan *    documentation and/or other materials provided with the distribution.
14d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan *
15d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan * SUCH DAMAGE.
26d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan */
27d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
28d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#ifndef CONTROL_H
29d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#define CONTROL_H
30d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
31d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#include "dhcpcd.h"
32d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
33d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan/* Limit queue size per fd */
34d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#define CONTROL_QUEUE_MAX	100
35d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
36d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanstruct fd_data {
37d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	TAILQ_ENTRY(fd_data) next;
38d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	char *data;
39d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	size_t data_len;
40d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	uint8_t freeit;
41d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan};
42d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel TanTAILQ_HEAD(fd_data_head, fd_data);
43d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
44d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanstruct fd_list {
45d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	TAILQ_ENTRY(fd_list) next;
46d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	struct dhcpcd_ctx *ctx;
47d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	int fd;
48d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	unsigned int flags;
49d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	struct fd_data_head queue;
50d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan	struct fd_data_head free_queue;
51d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan};
52d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel TanTAILQ_HEAD(fd_list_head, fd_list);
53d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
54d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#define FD_LISTEN	(1<<0)
55d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#define FD_UNPRIV	(1<<1)
56d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
57d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanint control_start(struct dhcpcd_ctx *, const char *);
58d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanint control_stop(struct dhcpcd_ctx *);
59d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanint control_open(struct dhcpcd_ctx *, const char *);
60d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanssize_t control_send(struct dhcpcd_ctx *, int, char * const *);
61d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanint control_queue(struct fd_list *fd, char *data, size_t data_len, uint8_t fit);
62d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tanvoid control_close(struct dhcpcd_ctx *ctx);
63d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan
64d7ed851d6fc26c5e7db96971dbe6b44342b97727Samuel Tan#endif
65