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
))))
54 /** Structure of response seems to be:
55 DWORD num_bytes_in_resp -- MUST be the same as q_u->max_read_size
58 DWORD sent_size -- sum of EVENTLOGRECORD lengths if records returned, 0 otherwise
59 DWORD real_size -- 0 if records returned, otherwise length of next record to be returned
61 bool eventlog_io_r_read_eventlog(const char *desc
,
62 EVENTLOG_Q_READ_EVENTLOG
*q_u
,
63 EVENTLOG_R_READ_EVENTLOG
*r_u
,
67 Eventlog_entry
*entry
;
68 uint32 record_written
= 0;
69 uint32 record_total
= 0;
74 prs_debug(ps
, depth
, desc
, "eventlog_io_r_read_eventlog");
77 /* First, see if we've read more logs than we can output */
79 if(r_u
->num_bytes_in_resp
> q_u
->max_read_size
) {
82 /* remove the size of the last entry from the list */
84 while(entry
->next
!= NULL
)
87 r_u
->num_bytes_in_resp
-= entry
->record
.length
;
89 /* do not output the last log entry */
95 record_total
= r_u
->num_records
;
97 if(r_u
->num_bytes_in_resp
!= 0)
98 r_u
->sent_size
= r_u
->num_bytes_in_resp
;
100 r_u
->real_size
= r_u
->bytes_in_next_record
;
104 if(!(prs_uint32("bytes in resp", ps
, depth
, &(q_u
->max_read_size
))))
107 while(entry
!= NULL
&& record_written
< record_total
)
109 DEBUG(11, ("eventlog_io_r_read_eventlog: writing record [%d] out of [%d].\n", record_written
, record_total
));
111 /* Encode the actual eventlog record record */
113 if(!(prs_uint32("length", ps
, depth
, &(entry
->record
.length
))))
115 if(!(prs_uint32("reserved", ps
, depth
, &(entry
->record
.reserved1
))))
117 if(!(prs_uint32("record number", ps
, depth
, &(entry
->record
.record_number
))))
119 if(!(prs_uint32("time generated", ps
, depth
, &(entry
->record
.time_generated
))))
121 if(!(prs_uint32("time written", ps
, depth
, &(entry
->record
.time_written
))))
123 if(!(prs_uint32("event id", ps
, depth
, &(entry
->record
.event_id
))))
125 if(!(prs_uint16("event type", ps
, depth
, &(entry
->record
.event_type
))))
127 if(!(prs_uint16("num strings", ps
, depth
, &(entry
->record
.num_strings
))))
129 if(!(prs_uint16("event category", ps
, depth
, &(entry
->record
.event_category
))))
131 if(!(prs_uint16("reserved2", ps
, depth
, &(entry
->record
.reserved2
))))
133 if(!(prs_uint32("closing record", ps
, depth
, &(entry
->record
.closing_record_number
))))
135 if(!(prs_uint32("string offset", ps
, depth
, &(entry
->record
.string_offset
))))
137 if(!(prs_uint32("user sid length", ps
, depth
, &(entry
->record
.user_sid_length
))))
139 if(!(prs_uint32("user sid offset", ps
, depth
, &(entry
->record
.user_sid_offset
))))
141 if(!(prs_uint32("data length", ps
, depth
, &(entry
->record
.data_length
))))
143 if(!(prs_uint32("data offset", ps
, depth
, &(entry
->record
.data_offset
))))
148 /* Now encoding data */
150 if(!(prs_uint8s(False
, "buffer", ps
, depth
, entry
->data
,
151 entry
->record
.length
- sizeof(Eventlog_record
) - sizeof(entry
->record
.length
))))
158 if(!(prs_uint32("length 2", ps
, depth
, &(entry
->record
.length
))))
164 } /* end of encoding EVENTLOGRECORD */
166 /* Now pad with whitespace until the end of the response buffer */
168 if (q_u
->max_read_size
- r_u
->num_bytes_in_resp
) {
169 if (!r_u
->end_of_entries_padding
) {
173 if(!(prs_uint8s(False
, "end of entries padding", ps
,
174 depth
, r_u
->end_of_entries_padding
,
175 (q_u
->max_read_size
- r_u
->num_bytes_in_resp
)))) {
176 free(r_u
->end_of_entries_padding
);
180 free(r_u
->end_of_entries_padding
);
183 /* We had better be DWORD aligned here */
185 if(!(prs_uint32("sent size", ps
, depth
, &(r_u
->sent_size
))))
187 if(!(prs_uint32("real size", ps
, depth
, &(r_u
->real_size
))))
189 if(!(prs_ntstatus("status code", ps
, depth
, &r_u
->status
)))