-
Notifications
You must be signed in to change notification settings - Fork 1
/
msgctx.h
61 lines (50 loc) · 1.54 KB
/
msgctx.h
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
/*
* network latency measurer
* Copyright (C) 2018 Ricardo Biehl Pasquali <pasqualirb@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MSGCTX_H
#define MSGCTX_H
/* TODO: is it necessary to include the two headers below? */
#include <sys/types.h>
#include <sys/socket.h>
struct msgctx {
/* memory used in recvmsg() */
void *memory;
struct msghdr msg;
/* the packet payload (IO vector->base will point to packet_header) */
struct iovec iov;
/*
* pointer to the buffer where the data is
* i.e. an alias to iov.iov_base
*/
void *data;
/*
* keep name_len and control_len because
* they can be modified by the kernel
*/
size_t name_len;
size_t control_len;
/* packet data length */
size_t len;
};
int
msgctx_recv(int sfd, struct msgctx *mctx, int flags);
void
msgctx_destroy(struct msgctx *mctx);
int
msgctx_init(struct msgctx *mctx, size_t buffer_len, size_t control_len,
size_t addr_len);
#endif /* MSGCTX_H */