From 160ead46dc13e908903e70e372bdafc2ba8f4615 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 5 Jun 2009 11:05:03 +0200 Subject: s3:smbd: implement smbd_smb2_request_error/done() as macros on top of the _ex() function metze --- source3/include/smb_macros.h | 3 --- source3/smbd/globals.h | 16 ++++++++++------ source3/smbd/smb2_server.c | 31 +++++++++++-------------------- source3/smbd/smb2_sesssetup.c | 3 ++- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 6dd9cab711..7528883c2d 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -339,7 +339,4 @@ extern const char toupper_ascii_fast_table[]; #define toupper_ascii_fast(c) toupper_ascii_fast_table[(unsigned int)(c)]; #endif -#define smbd_smb2_request_error(req, status) \ - smbd_smb2_request_error_((req), (status), __location__) - #endif /* _SMB_MACROS_H */ diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 4c90e8f66b..2e5bc913d0 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -176,14 +176,18 @@ void reply_smb2002(struct smb_request *req, uint16_t choice); void smbd_smb2_first_negprot(struct smbd_server_connection *conn, const uint8_t *inbuf, size_t size); -NTSTATUS smbd_smb2_request_error_(struct smbd_smb2_request *req, - NTSTATUS status, - const char *wherestr); +NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req, + NTSTATUS status, + DATA_BLOB *info, + const char *location); +#define smbd_smb2_request_error(req, status) \ + smbd_smb2_request_error_ex(req, status, NULL, __location__) NTSTATUS smbd_smb2_request_done_ex(struct smbd_smb2_request *req, NTSTATUS status, - DATA_BLOB body, DATA_BLOB *dyn); -NTSTATUS smbd_smb2_request_done(struct smbd_smb2_request *req, - DATA_BLOB body, DATA_BLOB *dyn); + DATA_BLOB body, DATA_BLOB *dyn, + const char *location); +#define smbd_smb2_request_done(req, body, dyn) \ + smbd_smb2_request_done_ex(req, NT_STATUS_OK, body, dyn, __location__) NTSTATUS smbd_smb2_request_check_session(struct smbd_smb2_request *req); NTSTATUS smbd_smb2_request_check_tcon(struct smbd_smb2_request *req); diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 5c4bdca3e5..f4dc7c4f46 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -583,17 +583,18 @@ static void smbd_smb2_request_writev_done(struct tevent_req *subreq) talloc_free(mem_pool); } -static NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req, +NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req, NTSTATUS status, - const char *wherestr, - DATA_BLOB *info) + DATA_BLOB *info, + const char *location) { uint8_t *outhdr; uint8_t *outbody; int i = req->current_idx; - DEBUG(10,("smbd_smb2_request_error_ex: idx[%d] status[%s] at %s |%s|\n", - i, nt_errstr(status), wherestr, info ? " +info" : "")); + DEBUG(10,("smbd_smb2_request_error_ex: idx[%d] status[%s] |%s| at %s\n", + i, nt_errstr(status), info ? " +info" : "", + location)); outhdr = (uint8_t *)req->out.vector[i].iov_base; @@ -620,15 +621,10 @@ static NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req, return smbd_smb2_request_reply(req); } -NTSTATUS smbd_smb2_request_error_(struct smbd_smb2_request *req, - NTSTATUS status, const char *wherestr) -{ - return smbd_smb2_request_error_ex(req, status, wherestr, NULL); -} - NTSTATUS smbd_smb2_request_done_ex(struct smbd_smb2_request *req, NTSTATUS status, - DATA_BLOB body, DATA_BLOB *dyn) + DATA_BLOB body, DATA_BLOB *dyn, + const char *location) { uint8_t *outhdr; uint8_t *outdyn; @@ -636,10 +632,11 @@ NTSTATUS smbd_smb2_request_done_ex(struct smbd_smb2_request *req, uint32_t next_command_ofs; DEBUG(10,("smbd_smb2_request_done_ex: " - "idx[%d] status[%s] body[%u] dyn[%s:%u]\n", + "idx[%d] status[%s] body[%u] dyn[%s:%u] at %s\n", i, nt_errstr(status), (unsigned int)body.length, dyn ? "yes": "no", - (unsigned int)(dyn ? dyn->length : 0))); + (unsigned int)(dyn ? dyn->length : 0), + location)); if (body.length < 2) { return smbd_smb2_request_error(req, NT_STATUS_INTERNAL_ERROR); @@ -690,12 +687,6 @@ NTSTATUS smbd_smb2_request_done_ex(struct smbd_smb2_request *req, return smbd_smb2_request_reply(req); } -NTSTATUS smbd_smb2_request_done(struct smbd_smb2_request *req, - DATA_BLOB body, DATA_BLOB *dyn) -{ - return smbd_smb2_request_done_ex(req, NT_STATUS_OK, body, dyn); -} - struct smbd_smb2_request_read_state { size_t missing; bool asked_for_header; diff --git a/source3/smbd/smb2_sesssetup.c b/source3/smbd/smb2_sesssetup.c index faf7bd3db3..b56f8bd5f6 100644 --- a/source3/smbd/smb2_sesssetup.c +++ b/source3/smbd/smb2_sesssetup.c @@ -114,7 +114,8 @@ NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *req) outdyn = out_security_buffer; - return smbd_smb2_request_done_ex(req, status, outbody, &outdyn); + return smbd_smb2_request_done_ex(req, status, outbody, &outdyn, + __location__); } static int smbd_smb2_session_destructor(struct smbd_smb2_session *session) -- cgit