r23055: Rewrite messages.c to use auto-generated marshalling in the tdb. I'm
[samba.git] / source3 / include / messages.h
1 /* 
2    Unix SMB/CIFS implementation.
3    messages.c header
4    Copyright (C) Andrew Tridgell 2000
5    Copyright (C) 2001, 2002 by Martin Pool
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _MESSAGES_H_
23 #define _MESSAGES_H_
24
25 /* general messages */
26 #define MSG_DEBUG               1
27 #define MSG_PING                2
28 #define MSG_PONG                3
29 #define MSG_PROFILE             4
30 #define MSG_REQ_DEBUGLEVEL      5
31 #define MSG_DEBUGLEVEL          6
32 #define MSG_REQ_PROFILELEVEL    7
33 #define MSG_PROFILELEVEL        8
34 #define MSG_REQ_POOL_USAGE      9
35 #define MSG_POOL_USAGE          10
36
37 /* If dmalloc is included, set a steady-state mark */
38 #define MSG_REQ_DMALLOC_MARK    11
39
40 /* If dmalloc is included, dump to the dmalloc log a description of
41  * what has changed since the last MARK */
42 #define MSG_REQ_DMALLOC_LOG_CHANGED     12
43
44 #define MSG_SHUTDOWN            13
45
46 /* nmbd messages */
47 #define MSG_FORCE_ELECTION 1001
48 #define MSG_WINS_NEW_ENTRY 1002
49 #define MSG_SEND_PACKET    1003
50
51 /* printing messages */
52 /* #define MSG_PRINTER_NOTIFY  2001*/ /* Obsolete */
53 #define MSG_PRINTER_NOTIFY2             2002
54
55 #define MSG_PRINTER_DRVUPGRADE          2101
56 #define MSG_PRINTERDATA_INIT_RESET      2102
57 #define MSG_PRINTER_UPDATE              2103
58 #define MSG_PRINTER_MOD                 2104
59
60 /* smbd messages */
61 #define MSG_SMB_CONF_UPDATED 3001
62 #define MSG_SMB_FORCE_TDIS   3002
63 #define MSG_SMB_SAM_SYNC     3003
64 #define MSG_SMB_SAM_REPL     3004
65 #define MSG_SMB_UNLOCK       3005
66 #define MSG_SMB_BREAK_REQUEST 3006
67 #define MSG_SMB_BREAK_RESPONSE 3007
68 #define MSG_SMB_ASYNC_LEVEL2_BREAK 3008
69 #define MSG_SMB_OPEN_RETRY   3009
70 #define MSG_SMB_KERNEL_BREAK 3010
71 #define MSG_SMB_FILE_RENAME  3011
72 #define MSG_SMB_INJECT_FAULT 3012
73 #define MSG_SMB_BLOCKING_LOCK_CANCEL 3013
74 #define MSG_SMB_NOTIFY       3014
75 #define MSG_SMB_STAT_CACHE_DELETE 3015
76 /*
77  * Samba4 compatibility
78  */
79 #define MSG_PVFS_NOTIFY       3016
80
81 /* winbind messages */
82 #define MSG_WINBIND_FINISHED     4001
83 #define MSG_WINBIND_FORGET_STATE 4002
84 #define MSG_WINBIND_ONLINE       4003
85 #define MSG_WINBIND_OFFLINE      4004
86 #define MSG_WINBIND_ONLINESTATUS 4005
87 #define MSG_WINBIND_TRY_TO_GO_ONLINE 4006
88 #define MSG_WINBIND_FAILED_TO_GO_ONLINE 4007
89
90 /* Flags to classify messages - used in message_send_all() */
91 /* Sender will filter by flag. */
92
93 #define FLAG_MSG_GENERAL        0x0001
94 #define FLAG_MSG_SMBD           0x0002
95 #define FLAG_MSG_NMBD           0x0004
96 #define FLAG_MSG_PRINT_NOTIFY   0x0008
97 #define FLAG_MSG_PRINT_GENERAL  0x0010
98
99 struct server_id {
100         pid_t pid;
101 };
102
103 struct messaging_context;
104 struct data_blob;
105
106 unsigned int messages_pending_for_pid(struct messaging_context *msg_ctx,
107                                       struct server_id pid);
108 void message_dispatch(struct messaging_context *msg_ctx);
109 BOOL message_send_all(struct messaging_context *msg_ctx,
110                       int msg_type,
111                       const void *buf, size_t len,
112                       int *n_sent);
113 void message_block(void);
114 void message_unblock(void);
115 struct event_context *messaging_event_context(struct messaging_context *msg_ctx);
116 struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, 
117                                          struct server_id server_id, 
118                                          struct event_context *ev);
119 NTSTATUS messaging_register(struct messaging_context *msg_ctx,
120                             void *private_data,
121                             uint32_t msg_type,
122                             void (*fn)(struct messaging_context *msg,
123                                        void *private_data, 
124                                        uint32_t msg_type, 
125                                        struct server_id server_id,
126                                        struct data_blob *data));
127 void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type,
128                           void *private_data);
129 NTSTATUS messaging_send(struct messaging_context *msg_ctx,
130                         struct server_id server, 
131                         uint32_t msg_type, const struct data_blob *data);
132 NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
133                             struct server_id server, uint32_t msg_type,
134                             const uint8 *buf, size_t len);
135
136 #endif