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