| 1 |
#pragma once |
| 2 |
|
| 3 |
/* |
| 4 |
* Socket Listener |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <c-list.h> |
| 8 |
#include <c-stdaux.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include "bus/policy.h" |
| 11 |
#include "util/dispatch.h" |
| 12 |
|
| 13 |
typedef struct Bus Bus; |
| 14 |
typedef struct DispatchContext DispatchContext; |
| 15 |
typedef struct Listener Listener; |
| 16 |
|
| 17 |
struct Listener { |
| 18 |
Bus *bus; |
| 19 |
char guid[16]; |
| 20 |
int socket_fd; |
| 21 |
DispatchFile socket_file; |
| 22 |
PolicyRegistry *policy; |
| 23 |
CList peer_list; |
| 24 |
}; |
| 25 |
|
| 26 |
#define LISTENER_NULL(_x) { \ |
| 27 |
.socket_fd = -1, \ |
| 28 |
.socket_file = DISPATCH_FILE_NULL((_x).socket_file), \ |
| 29 |
.peer_list = C_LIST_INIT((_x).peer_list), \ |
| 30 |
} |
| 31 |
|
| 32 |
int listener_init_with_fd(Listener *listener, |
| 33 |
Bus *bus, |
| 34 |
DispatchContext *dispatcher, |
| 35 |
int socket_fd, |
| 36 |
PolicyRegistry *policy); |
| 37 |
Listener *listener_free(Listener *free); |
| 38 |
void listener_deinit(Listener *listener); |
| 39 |
|
| 40 |
int listener_set_policy(Listener *listener, PolicyRegistry *policy); |
| 41 |
|
| 42 |
C_DEFINE_CLEANUP(Listener *, listener_deinit); |