2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Marcin Krzysztof Porwit 2005.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
23 #define DBGC_CLASS DBGC_RPC_PARSE
25 /********************************************************************
26 ********************************************************************/
28 bool eventlog_io_q_read_eventlog(const char *desc
, EVENTLOG_Q_READ_EVENTLOG
*q_u
,
29 prs_struct
*ps
, int depth
)
34 prs_debug(ps
, depth
, desc
, "eventlog_io_q_read_eventlog");
40 if(!(smb_io_pol_hnd("log handle", &(q_u
->handle
), ps
, depth
)))
43 if(!(prs_uint32("read flags", ps
, depth
, &(q_u
->flags
))))
46 if(!(prs_uint32("read offset", ps
, depth
, &(q_u
->offset
))))
49 if(!(prs_uint32("read buf size", ps
, depth
, &(q_u
->max_read_size
))))
55 static bool smb_io_eventlog_entry(const char *name
, prs_struct
*ps
, int depth
, Eventlog_entry
*entry
)
60 prs_debug(ps
, depth
, name
, "smb_io_eventlog_entry");
66 if(!(prs_uint32("length", ps
, depth
, &(entry
->record
.length
))))
68 if(!(prs_uint32("reserved", ps
, depth
, &(entry
->record
.reserved1
))))
70 if(!(prs_uint32("record number", ps
, depth
, &(entry
->record
.record_number
))))
72 if(!(prs_uint32("time generated", ps
, depth
, &(entry
->record
.time_generated
))))
74 if(!(prs_uint32("time written", ps
, depth
, &(entry
->record
.time_written
))))
76 if(!(prs_uint32("event id", ps
, depth
, &(entry
->record
.event_id
))))
78 if(!(prs_uint16("event type", ps
, depth
, &(entry
->record
.event_type
))))
80 if(!(prs_uint16("num strings", ps
, depth
, &(entry
->record
.num_strings
))))
82 if(!(prs_uint16("event category", ps
, depth
, &(entry
->record
.event_category
))))
84 if(!(prs_uint16("reserved2", ps
, depth
, &(entry
->record
.reserved2
))))
86 if(!(prs_uint32("closing record", ps
, depth
, &(entry
->record
.closing_record_number
))))
88 if(!(prs_uint32("string offset", ps
, depth
, &(entry
->record
.string_offset
))))
90 if(!(prs_uint32("user sid length", ps
, depth
, &(entry
->record
.user_sid_length
))))
92 if(!(prs_uint32("user sid offset", ps
, depth
, &(entry
->record
.user_sid_offset
))))
94 if(!(prs_uint32("data length", ps
, depth
, &(entry
->record
.data_length
))))
96 if(!(prs_uint32("data offset", ps
, depth
, &(entry
->record
.data_offset
))))
101 /* Now encoding data */
103 if(!(prs_uint8s(False
, "buffer", ps
, depth
, entry
->data
,
104 entry
->record
.length
- sizeof(Eventlog_record
) - sizeof(entry
->record
.length
))))
112 if(!(prs_uint32("length 2", ps
, depth
, &(entry
->record
.length
))))
118 /** Structure of response seems to be:
119 DWORD num_bytes_in_resp -- MUST be the same as q_u->max_read_size
121 EVENTLOGRECORD record
122 DWORD sent_size -- sum of EVENTLOGRECORD lengths if records returned, 0 otherwise
123 DWORD real_size -- 0 if records returned, otherwise length of next record to be returned
125 bool eventlog_io_r_read_eventlog(const char *desc
,
126 EVENTLOG_Q_READ_EVENTLOG
*q_u
,
127 EVENTLOG_R_READ_EVENTLOG
*r_u
,
131 Eventlog_entry
*entry
;
132 uint32 record_written
= 0;
133 uint32 record_total
= 0;
138 prs_debug(ps
, depth
, desc
, "eventlog_io_r_read_eventlog");
141 /* First, see if we've read more logs than we can output */
143 if(r_u
->num_bytes_in_resp
> q_u
->max_read_size
) {
146 /* remove the size of the last entry from the list */
148 while(entry
->next
!= NULL
)
151 r_u
->num_bytes_in_resp
-= entry
->record
.length
;
153 /* do not output the last log entry */
159 record_total
= r_u
->num_records
;
161 if(r_u
->num_bytes_in_resp
!= 0)
162 r_u
->sent_size
= r_u
->num_bytes_in_resp
;
164 r_u
->real_size
= r_u
->bytes_in_next_record
;
168 if(!(prs_uint32("bytes in resp", ps
, depth
, &(q_u
->max_read_size
))))
171 while(entry
!= NULL
&& record_written
< record_total
)
173 DEBUG(11, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written
, record_total
));
175 /* Encode the actual eventlog record record */
177 if (!(smb_io_eventlog_entry("entry", ps
, depth
, entry
)))
183 } /* end of encoding EVENTLOGRECORD */
185 /* Now pad with whitespace until the end of the response buffer */
187 if (q_u
->max_read_size
- r_u
->num_bytes_in_resp
) {
188 if (!r_u
->end_of_entries_padding
) {
192 if(!(prs_uint8s(False
, "end of entries padding", ps
,
193 depth
, r_u
->end_of_entries_padding
,
194 (q_u
->max_read_size
- r_u
->num_bytes_in_resp
)))) {
195 free(r_u
->end_of_entries_padding
);
199 free(r_u
->end_of_entries_padding
);
202 /* We had better be DWORD aligned here */
204 if(!(prs_uint32("sent size", ps
, depth
, &(r_u
->sent_size
))))
206 if(!(prs_uint32("real size", ps
, depth
, &(r_u
->real_size
))))
208 if(!(prs_ntstatus("status code", ps
, depth
, &r_u
->status
)))