]> arthur.barton.de Git - netatalk.git/blob - include/atalk/fce_api.h
fce: FCE version 2 with new event types and new config options
[netatalk.git] / include / atalk / fce_api.h
1 /* 
2  * File:   fce_api.h
3  * Author: mw
4  *
5  * Created on 1. Oktober 2010, 21:35
6  *
7  * API calls for file change event api
8  */
9
10 #ifndef _FCE_API_H
11 #define _FCE_API_H
12
13 #include <atalk/globals.h>
14
15 #define FCE_PACKET_VERSION  2
16
17 /* fce_packet.mode */
18 #define FCE_FILE_MODIFY     1
19 #define FCE_FILE_DELETE     2
20 #define FCE_DIR_DELETE      3
21 #define FCE_FILE_CREATE     4
22 #define FCE_DIR_CREATE      5
23 #define FCE_FILE_MOVE       6
24 #define FCE_DIR_MOVE        7
25 #define FCE_LOGIN           8
26 #define FCE_LOGOUT          9
27 #define FCE_CONN_START     42
28 #define FCE_CONN_BROKEN    99
29
30 #define FCE_FIRST_EVENT     FCE_FILE_MODIFY /* keep in sync with last file event above */
31 #define FCE_LAST_EVENT      FCE_DIR_CREATE  /* keep in sync with last file event above */
32
33 /* fce_packet.fce_magic */
34 #define FCE_PACKET_MAGIC  "at_fcapi"
35
36 /* flags for "fce_ev_info" of additional info to send in events */
37 #define FCE_EV_INFO_PID     (1 << 0)
38 #define FCE_EV_INFO_USER    (1 << 1)
39 #define FCE_EV_INFO_SRCPATH (1 << 2)
40
41 /*
42  * Network payload of an FCE packet, version 1
43  *
44  *      1         2         3         4         5         6         7          8
45  * +---------+---------+---------+---------+---------+---------+----------+----------+
46  * |                                   FCE magic                                     |
47  * +---------+---------+---------+---------+---------+---------+----------+----------+
48  * | version |
49  * +---------+
50  * |  event  |
51  * +---------+-----------------------------+
52  * |               event ID                |
53  * +-------------------+-------------------+ . . . .
54  * |     pathlen       | path
55  * +-------------------+------ . . . . . . . . . . .
56  *
57  *
58  * Network payload of an FCE packet, version 2
59  *
60  *      1         2         3         4         5         6         7          8
61  * +---------+---------+---------+---------+---------+---------+----------+----------+
62  * |                                   FCE magic                                     |
63  * +---------+---------+---------+---------+---------+---------+----------+----------+
64  * | version |
65  * +---------+
66  * | options |
67  * +---------+
68  * |  event  |
69  * +---------+
70  * | padding |
71  * +---------+---------+---------+---------+---------+---------+----------+----------+
72  * |                                    reserved                                     |
73  * +---------+---------+---------+---------+---------+---------+----------+----------+
74  * |               event ID                |
75  * +---------+---------+---------+---------+
76  * ... optional:
77  * +---------+---------+---------+---------+---------+---------+----------+----------+
78  * |                                      pid                                        |
79  * +---------+---------+---------+---------+---------+---------+----------+----------+
80  * ...
81  * ... optional:
82  * +-------------------+----------  . . . .
83  * |  username length  | username
84  * +-------------------+----------  . . . .
85  * ...
86  * +-------------------+------  . . . . . .
87  * |     pathlen       | path
88  * +-------------------+------  . . . . . .
89  * ... optional:
90  * +-------------------+------------- . . .
91  * |     pathlen       | source path
92  * +-------------------+------------- . . .
93  *
94  * version      = 2
95  * options      = bitfield:
96  *                    0: pid present
97  *                    1: username present
98  *                    2: source path present
99  * pid          = optional pid
100  * username     = optional username
101  * source path  = optional source path
102  */
103
104 struct fce_packet {
105     char          fcep_magic[8];
106     unsigned char fcep_version;
107     unsigned char fcep_options;
108     unsigned char fcep_event;
109     uint32_t      fcep_event_id;
110     uint64_t      fcep_pid;
111     uint16_t      fcep_userlen;
112     char          fcep_user[MAXPATHLEN];
113     uint16_t      fcep_pathlen1;
114     char          fcep_path1[MAXPATHLEN];
115     uint16_t      fcep_pathlen2;
116     char          fcep_path2[MAXPATHLEN];
117 };
118
119 typedef uint32_t fce_ev_t;
120
121 struct path;
122 struct ofork;
123
124 void fce_pending_events(const AFPObj *obj);
125 int fce_register(const AFPObj *obj, fce_ev_t event, const char *path, const char *oldpath);
126 int fce_add_udp_socket(const char *target );  // IP or IP:Port
127 int fce_set_coalesce(const char *coalesce_opt ); // all|delete|create
128 int fce_set_events(const char *events);     /* fmod,fdel,ddel,fcre,dcre */
129
130 #define FCE_DEFAULT_PORT 12250
131 #define FCE_DEFAULT_PORT_STRING "12250"
132
133 #endif  /* _FCE_API_H */
134