netatalk: server_ipc.h Source File

netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
server_ipc.h
Go to the documentation of this file.
1#ifndef ATALK_SERVER_IPC_H
2#define ATALK_SERVER_IPC_H
3
4#include <stdint.h>
5
6#include <atalk/cnid.h>
7#include <atalk/globals.h>
8#include <atalk/server_child.h>
9
10/* IPC wire format constants — moved from server_ipc.c so receivers (Eg dircache.c)
11 * can parse the wire format. 14-byte header: cmd(2) + pid(4) + uid(4) + len(4) */
12#define IPC_HEADERLEN 14
13#define IPC_MAXMSGSIZE 90
14
15/* Remember to add IPC commands to server_ipc.c:ipc_cmd_str[] */
16#define IPC_DISCOLDSESSION 0
17#define IPC_GETSESSION 1
18#define IPC_STATE 2
19#define IPC_VOLUMES 3
20#define IPC_LOGINDONE 4
21#define IPC_CACHE_HINT 5
22#define IPC_SESSIONTOKEN 6
23
24/* Cache hint types — carried in struct ipc_cache_hint_payload.event */
25#define CACHE_HINT_REFRESH 0
26#define CACHE_HINT_DELETE 1
27#define CACHE_HINT_DELETE_CHILDREN 2
28
29/* Hint payload — sent inside standard IPC wire header framing.
30 * Packed to guarantee sizeof == 8. vid and cnid in network byte order. */
31 struct __attribute__((packed)) ipc_cache_hint_payload {
32 uint8_t event; /* Hint type: CACHE_HINT_REFRESH/DELETE/DELETE_CHILDREN */
33 uint8_t reserved; /* Alignment padding (could be version field in future) */
34 uint16_t vid; /* Volume ID — network byte order (matches vol->v_vid) */
35 cnid_t cnid; /* CNID of affected file/dir — network byte order */
36};
37
38_Static_assert(sizeof(struct ipc_cache_hint_payload) == 8,
39 "Hint payload must be exactly 8 bytes");
40
41/* Hint buffer capacity — main.c checks this to trigger immediate flush
42 * when buffer is full after fd event processing. */
43#define HINT_BUF_SIZE 128
44
45/* Flush interval for poll timeout — main.c uses this to set poll timeout
46 * when hints are buffered. 50ms balances latency vs syscall overhead. */
47#define HINT_FLUSH_INTERVAL_MS 50
48
49extern int ipc_server_read(server_child_t *children, int fd);
50extern int ipc_child_write(AFPObj *obj, uint16_t command, size_t len,
51 void *token);
52extern int ipc_child_state(AFPObj *obj, uint16_t state);
53
54extern int ipc_send_cache_hint(const AFPObj *obj, uint16_t vid, cnid_t cnid,
55 uint8_t event);
56extern unsigned long long ipc_get_hints_sent(void);
57extern unsigned long long ipc_get_hints_dropped(void);
58
59/* Poll-driven hint flush API (parent-side only, single-threaded) */
60extern void hint_flush_pending(server_child_t *children);
61extern int hint_buf_count(void);
62
63#endif /* ATALK_SERVER_IPC_H */
cnid_t
uint32_t cnid_t
Definition adouble.h:156
children
static server_child_t * children
Definition asp_getsess.c:43
cnid.h
vid
static uint16_t vid
Definition fuzz.c:51
globals.h
state
static int state
Definition magics.c:23
obj
static AFPObj obj
Definition netatalk.c:69
server_child.h
data structures and utility functions for child processes
ipc_server_read
int ipc_server_read(server_child_t *children, int fd)
Read a IPC message from a child.
Definition server_ipc.c:363
ipc_send_cache_hint
int ipc_send_cache_hint(const AFPObj *obj, uint16_t vid, cnid_t cnid, uint8_t event)
Send a dircache invalidation hint from child to parent.
Definition server_ipc.c:718
ipc_child_state
int ipc_child_state(AFPObj *obj, uint16_t state)
Definition server_ipc.c:541
hint_buf_count
int hint_buf_count(void)
Return current number of buffered hints.
Definition server_ipc.c:557
hint_flush_pending
void hint_flush_pending(server_child_t *children)
Flush all buffered hints to sibling children.
Definition server_ipc.c:580
ipc_get_hints_dropped
unsigned long long ipc_get_hints_dropped(void)
Definition server_ipc.c:689
ipc_child_write
int ipc_child_write(AFPObj *obj, uint16_t command, size_t len, void *token)
Definition server_ipc.c:499
ipc_get_hints_sent
unsigned long long ipc_get_hints_sent(void)
Definition server_ipc.c:684
AFPObj
Definition globals.h:166
ipc_cache_hint_payload
Definition server_ipc.h:31
ipc_cache_hint_payload::reserved
uint8_t reserved
Definition server_ipc.h:33
ipc_cache_hint_payload::event
uint8_t event
Definition server_ipc.h:32
ipc_cache_hint_payload::cnid
cnid_t cnid
Definition server_ipc.h:35
ipc_cache_hint_payload::vid
uint16_t vid
Definition server_ipc.h:34
server_child_t
Definition server_child.h:47