-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathif_utils.h
More file actions
65 lines (45 loc) · 2.25 KB
/
Copy pathif_utils.h
File metadata and controls
65 lines (45 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2023-2025, Ericsson AB and Ericsson Telecommunication Hungary
// All rights reserved.
#ifndef DNT_IF_UTILS_H
#define DNT_IF_UTILS_H
#include "interface.h"
#include "notification.h"
#include "packet.h"
#include <stdbool.h>
struct msghdr;
void enable_rx_tstamp(int sock, const char *sockname,
const char *ifname/*, enum hwtstamp_rx_filters filter*/);
bool enable_so_txtime(int sock, const char *sockname, const char *ifname, bool deadline);
typedef void msghdr_process_cb(struct msghdr *msg, struct Packet *p, void *userdata);
// receives a packet on @iface
// blocks if there is nothing in the receive buffer!
// @returns NULL on error, or when we have too many packets (never returns dummy packet)
// the msghdr is passed to the @msg_cb callback if it's not NULL
struct Packet *iface_common_recv(struct Interface *iface, msghdr_process_cb *msg_cb, void *userdata);
// sends a packet on @socket, which can be different from @iface->recvfd
// @dst and @dstlen should be compatible with the type of @socket
// @returns true on succes
bool iface_common_send(struct Interface *iface, struct Packet *p, int socket, void *dst, unsigned dstlen);
// queries the parsetree of @iface, and runs the returned iterator
// @returns true if a known stream was found for @p
bool iface_common_process(struct Interface *iface, struct Packet *p);
struct MonitorState;
// @returns a handle to the monitoring object or NULL on error
struct MonitorState *monitor_error_queue(int socket, int family, const char *name);
// always @returns NULL
struct MonitorState *stop_monitoring_error_queue(struct MonitorState *st);
// @self must be struct Interface
NotificationLevel iface_notification_pull_fn(void *self, struct JsonValue **msg);
// debug helper for getifaddrs()
struct ifaddrs;
void print_ifaddrs(struct ifaddrs *ifa);
// HEX dumps the packet
void dump_packet(char *buffer, int n);
// helper for the type-specific constructors
#define _NEW_IFACE(type_) \
struct Interface *iface = calloc_struct(Interface); \
iface->name = strdup(name); \
iface->reference_count = 1; \
iface->type = type_; \
iface->state = IFSTATE_INIT
#endif // DNT_IF_UTILS_H