2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Marcin Krzysztof Porwit 2005.
5 * Copyright (C) Gerald Carter 2005 - 2007
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.
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.
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.
25 #define DBGC_CLASS DBGC_RPC_SRV
27 static BOOL
proxy_eventlog_call(pipes_struct
*p
, uint8 opnum
)
29 struct api_struct
*fns
;
32 eventlog_get_pipe_fns(&fns
, &n_fns
);
37 if (fns
[opnum
].opnum
!= opnum
) {
38 smb_panic("EVENTLOG function table not sorted\n");
41 return fns
[opnum
].fn(p
);
44 static BOOL
api_eventlog_open_eventlog(pipes_struct
*p
)
46 EVENTLOG_Q_OPEN_EVENTLOG q_u
;
47 EVENTLOG_R_OPEN_EVENTLOG r_u
;
48 prs_struct
*data
= &p
->in_data
.data
;
49 prs_struct
*rdata
= &p
->out_data
.rdata
;
54 if (!(eventlog_io_q_open_eventlog("", &q_u
, data
, 0))) {
55 DEBUG(0, ("eventlog_io_q_open_eventlog: unable to unmarshall EVENTLOG_Q_OPEN_EVENTLOG.\n"));
59 r_u
.status
= _eventlog_open_eventlog(p
, &q_u
, &r_u
);
61 if (!(eventlog_io_r_open_eventlog("", &r_u
, rdata
, 0))) {
62 DEBUG(0, ("eventlog_io_r_open_eventlog: unable to marshall EVENTLOG_R_OPEN_EVENTLOG.\n"));
69 static BOOL
api_eventlog_close_eventlog(pipes_struct
*p
)
71 return proxy_eventlog_call( p
, DCERPC_EVENTLOG_CLOSEEVENTLOG
);
74 static BOOL
api_eventlog_get_num_records(pipes_struct
*p
)
76 EVENTLOG_Q_GET_NUM_RECORDS q_u
;
77 EVENTLOG_R_GET_NUM_RECORDS r_u
;
78 prs_struct
*data
= &p
->in_data
.data
;
79 prs_struct
*rdata
= &p
->out_data
.rdata
;
84 if (!(eventlog_io_q_get_num_records("", &q_u
, data
, 0))) {
85 DEBUG(0, ("eventlog_io_q_get_num_records: unable to unmarshall EVENTLOG_Q_GET_NUM_RECORDS.\n"));
89 r_u
.status
= _eventlog_get_num_records(p
, &q_u
, &r_u
);
91 if (!(eventlog_io_r_get_num_records("", &r_u
, rdata
, 0))) {
92 DEBUG(0, ("eventlog_io_r_get_num_records: unable to marshall EVENTLOG_R_GET_NUM_RECORDS.\n"));
99 static BOOL
api_eventlog_get_oldest_entry(pipes_struct
*p
)
101 EVENTLOG_Q_GET_OLDEST_ENTRY q_u
;
102 EVENTLOG_R_GET_OLDEST_ENTRY r_u
;
103 prs_struct
*data
= &p
->in_data
.data
;
104 prs_struct
*rdata
= &p
->out_data
.rdata
;
109 if (!(eventlog_io_q_get_oldest_entry("", &q_u
, data
, 0))) {
110 DEBUG(0, ("eventlog_io_q_get_oldest_entry: unable to unmarshall EVENTLOG_Q_GET_OLDEST_ENTRY.\n"));
114 r_u
.status
= _eventlog_get_oldest_entry(p
, &q_u
, &r_u
);
116 if (!(eventlog_io_r_get_oldest_entry("", &r_u
, rdata
, 0))) {
117 DEBUG(0, ("eventlog_io_r_get_oldest_entry: unable to marshall EVENTLOG_R_GET_OLDEST_ENTRY.\n"));
124 static BOOL
api_eventlog_read_eventlog(pipes_struct
*p
)
126 EVENTLOG_Q_READ_EVENTLOG q_u
;
127 EVENTLOG_R_READ_EVENTLOG r_u
;
128 prs_struct
*data
= &p
->in_data
.data
;
129 prs_struct
*rdata
= &p
->out_data
.rdata
;
134 if (!(eventlog_io_q_read_eventlog("", &q_u
, data
, 0))) {
135 DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n"));
139 r_u
.status
= _eventlog_read_eventlog(p
, &q_u
, &r_u
);
141 if (!(eventlog_io_r_read_eventlog("", &q_u
, &r_u
, rdata
, 0))) {
142 DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n"));
149 static BOOL
api_eventlog_clear_eventlog(pipes_struct
*p
)
151 EVENTLOG_Q_CLEAR_EVENTLOG q_u
;
152 EVENTLOG_R_CLEAR_EVENTLOG r_u
;
153 prs_struct
*data
= &p
->in_data
.data
;
154 prs_struct
*rdata
= &p
->out_data
.rdata
;
159 if (!(eventlog_io_q_clear_eventlog("", &q_u
, data
, 0))) {
160 DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to unmarshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
164 r_u
.status
= _eventlog_clear_eventlog(p
, &q_u
, &r_u
);
166 if (!(eventlog_io_r_clear_eventlog("", &r_u
, rdata
, 0))) {
167 DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to marshall EVENTLOG_Q_CLEAR_EVENTLOG.\n"));
175 \pipe\eventlog commands
177 struct api_struct api_eventlog_cmds
[] =
179 {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG
, api_eventlog_open_eventlog
},
180 {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG
, api_eventlog_close_eventlog
},
181 {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS
, api_eventlog_get_num_records
},
182 {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY
, api_eventlog_get_oldest_entry
},
183 {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG
, api_eventlog_read_eventlog
},
184 {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG
, api_eventlog_clear_eventlog
}
187 NTSTATUS
rpc_eventlog2_init(void)
189 return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION
,
190 "eventlog", "eventlog", api_eventlog_cmds
,
191 sizeof(api_eventlog_cmds
)/sizeof(struct api_struct
));
194 void eventlog2_get_pipe_fns(struct api_struct
**fns
, int *n_fns
)
196 *fns
= api_eventlog_cmds
;
197 *n_fns
= sizeof(api_eventlog_cmds
) / sizeof(struct api_struct
);