libelec
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
libelec_types_net.h
1
/*
2
* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
*/
6
/*
7
* Copyright 2023 Saso Kiselkov. All rights reserved.
8
*/
9
10
#ifndef __LIBELEC_TYPES_NET_H__
11
#define __LIBELEC_TYPES_NET_H__
12
13
#include <stdint.h>
14
15
#include <acfutils/delay_line.h>
16
#include <acfutils/list.h>
17
18
#include <netlink.h>
19
20
#ifdef __cplusplus
21
extern
"C"
{
22
#endif
23
24
#ifndef LIBELEC_WITH_NETLINK
25
#error "Building this file requires netlink support"
26
#endif
27
28
typedef
struct
{
29
netlink_conn_id_t conn_id;
30
uint8_t *map;
/* NETMAPSZ bytes */
31
unsigned
num_active;
32
delay_line_t kill_delay;
33
list_node_t node;
/* net_send.conns_list node */
34
}
net_conn_t
;
35
36
#define NET_REQ_MAP 0x0001
/* net_req_map_t */
37
38
typedef
struct
{
39
uint16_t version;
40
uint16_t req;
41
}
net_req_t
;
42
43
typedef
struct
{
44
uint16_t version;
45
uint16_t req;
46
uint64_t conf_crc;
47
uint8_t map[0];
/* variable length */
48
}
net_req_map_t
;
49
50
enum
{
51
LIBELEC_NET_FLAG_FAILED = 1 << 0,
52
LIBELEC_NET_FLAG_SHORTED = 1 << 1
53
};
54
55
#define NET_REP_COMPS 0x0001
/* net_rep_comps_t */
56
57
typedef
struct
{
58
uint16_t version;
59
uint16_t rep;
60
}
net_rep_t
;
61
62
typedef
struct
{
63
uint16_t idx;
/* component index */
64
uint16_t flags;
/* LIBELEC_NET_FLAG_* mask */
65
uint16_t in_volts;
/* 0.05 V */
66
uint16_t out_volts;
/* 0.05 V */
67
uint16_t in_amps;
/* 0.025 Amps */
68
uint16_t out_amps;
/* 0.025 Amps */
69
uint16_t in_freq;
/* 0.05 Hz */
70
uint16_t out_freq;
/* 0.05 Hz */
71
uint16_t leak_factor;
/* 1/10000th */
72
}
net_comp_data_t
;
73
74
typedef
struct
{
75
uint16_t version;
76
uint16_t rep;
77
uint64_t conf_crc;
78
uint16_t n_comps;
79
net_comp_data_t
comps[0];
/* variable length */
80
}
net_rep_comps_t
;
81
82
#ifdef __cplusplus
83
}
84
#endif
85
86
#endif
/* __LIBELEC_TYPES_NET_H__ */
net_comp_data_t
Definition:
libelec_types_net.h:62
net_conn_t
Definition:
libelec_types_net.h:28
net_rep_comps_t
Definition:
libelec_types_net.h:74
net_rep_t
Definition:
libelec_types_net.h:57
net_req_map_t
Definition:
libelec_types_net.h:43
net_req_t
Definition:
libelec_types_net.h:38
Generated by
1.9.1