Changeset 342 for branches/samba-3.3.x/source/libsmb
- Timestamp:
- Oct 30, 2009, 9:39:05 AM (16 years ago)
- Location:
- branches/samba-3.3.x/source/libsmb
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/libsmb/async_smb.c
r221 r342 239 239 } 240 240 241 if ((raw_pdu_len == 4) && (CVAL(pdu, 0) == SMBkeepalive)) { 242 DEBUG(10, ("Got keepalive\n")); 243 TALLOC_FREE(pdu); 244 return; 245 } 246 241 247 /* 242 248 * TODO: Handle oplock break requests -
branches/samba-3.3.x/source/libsmb/clireadwrite.c
r206 r342 155 155 } 156 156 157 struct cli_readall_state { 158 struct cli_state *cli; 159 uint16_t fnum; 160 off_t start_offset; 161 size_t size; 162 size_t received; 163 uint8_t *buf; 164 }; 165 166 static void cli_readall_done(struct async_req *subreq); 167 168 static struct async_req *cli_readall_send(TALLOC_CTX *mem_ctx, 169 struct cli_state *cli, 170 uint16_t fnum, 171 off_t offset, size_t size) 172 { 173 struct async_req *req, *subreq; 174 struct cli_readall_state *state; 175 176 req = async_req_new(mem_ctx, cli->event_ctx); 177 if (req == NULL) { 178 return NULL; 179 } 180 state = talloc(req, struct cli_readall_state); 181 if (state == NULL) { 182 TALLOC_FREE(req); 183 return NULL; 184 } 185 req->private_data = state; 186 187 state->cli = cli; 188 state->fnum = fnum; 189 state->start_offset = offset; 190 state->size = size; 191 state->received = 0; 192 state->buf = NULL; 193 194 subreq = cli_read_andx_send(state, cli, fnum, offset, size); 195 if (subreq == NULL) { 196 TALLOC_FREE(req); 197 return NULL; 198 } 199 subreq->async.fn = cli_readall_done; 200 subreq->async.priv = req; 201 return req; 202 } 203 204 static void cli_readall_done(struct async_req *subreq) 205 { 206 struct async_req *req = talloc_get_type_abort( 207 subreq->async.priv, struct async_req); 208 struct cli_readall_state *state = talloc_get_type_abort( 209 req->private_data, struct cli_readall_state); 210 ssize_t received; 211 uint8_t *buf; 212 NTSTATUS status; 213 214 status = cli_read_andx_recv(subreq, &received, &buf); 215 if (!NT_STATUS_IS_OK(status)) { 216 async_req_error(req, status); 217 return; 218 } 219 220 if (received == 0) { 221 /* EOF */ 222 async_req_done(req); 223 return; 224 } 225 226 if ((state->received == 0) && (received == state->size)) { 227 /* Ideal case: Got it all in one run */ 228 state->buf = buf; 229 state->received += received; 230 async_req_done(req); 231 return; 232 } 233 234 /* 235 * We got a short read, issue a read for the 236 * rest. Unfortunately we have to allocate the buffer 237 * ourselves now, as our caller expects to receive a single 238 * buffer. cli_read_andx does it from the buffer received from 239 * the net, but with a short read we have to put it together 240 * from several reads. 241 */ 242 243 if (state->buf == NULL) { 244 state->buf = talloc_array(state, uint8_t, state->size); 245 if (async_req_nomem(state->buf, req)) { 246 return; 247 } 248 } 249 memcpy(state->buf + state->received, buf, received); 250 state->received += received; 251 252 TALLOC_FREE(subreq); 253 254 if (state->received >= state->size) { 255 async_req_done(req); 256 return; 257 } 258 259 subreq = cli_read_andx_send(state, state->cli, state->fnum, 260 state->start_offset + state->received, 261 state->size - state->received); 262 if (async_req_nomem(subreq, req)) { 263 return; 264 } 265 subreq->async.fn = cli_readall_done; 266 subreq->async.priv = req; 267 } 268 269 static NTSTATUS cli_readall_recv(struct async_req *req, ssize_t *received, 270 uint8_t **rcvbuf) 271 { 272 struct cli_readall_state *state = talloc_get_type_abort( 273 req->private_data, struct cli_readall_state); 274 275 SMB_ASSERT(req->state >= ASYNC_REQ_DONE); 276 if (req->state == ASYNC_REQ_ERROR) { 277 return req->status; 278 } 279 *received = state->received; 280 *rcvbuf = state->buf; 281 return NT_STATUS_OK; 282 } 283 157 284 /* 158 285 * Parallel read support. … … 163 290 */ 164 291 292 struct cli_pull_subreq { 293 struct async_req *req; 294 size_t received; 295 uint8_t *buf; 296 }; 297 165 298 struct cli_pull_state { 166 299 struct async_req *req; … … 180 313 */ 181 314 int num_reqs; 182 struct async_req **reqs;315 struct cli_pull_subreq *reqs; 183 316 184 317 /* … … 269 402 state->num_reqs = MIN(state->num_reqs, cli->max_mux); 270 403 271 state->reqs = TALLOC_ZERO_ARRAY(state, struct async_req *,404 state->reqs = TALLOC_ZERO_ARRAY(state, struct cli_pull_subreq, 272 405 state->num_reqs); 273 406 if (state->reqs == NULL) { … … 289 422 request_thistime = MIN(size_left, state->chunk_size); 290 423 291 state->reqs[i] = cli_read_andx_send(424 state->reqs[i].req = cli_readall_send( 292 425 state->reqs, cli, fnum, 293 426 state->start_offset + state->requested, 294 427 request_thistime); 295 428 296 if (state->reqs[i] == NULL) {429 if (state->reqs[i].req == NULL) { 297 430 goto failed; 298 431 } 299 432 300 state->reqs[i] ->async.fn = cli_pull_read_done;301 state->reqs[i] ->async.priv = result;433 state->reqs[i].req->async.fn = cli_pull_read_done; 434 state->reqs[i].req->async.priv = result; 302 435 303 436 state->requested += request_thistime; … … 321 454 struct cli_pull_state *state = talloc_get_type_abort( 322 455 pull_req->private_data, struct cli_pull_state); 323 struct cli_request *read_state = cli_request_get(read_req); 456 ssize_t received; 457 uint8_t *buf; 324 458 NTSTATUS status; 325 326 status = cli_read_andx_recv(read_req, &read_state->data.read.received, 327 &read_state->data.read.rcvbuf);459 int i; 460 461 status = cli_readall_recv(read_req, &received, &buf); 328 462 if (!NT_STATUS_IS_OK(status)) { 329 463 async_req_error(state->req, status); 330 464 return; 331 465 } 466 467 for (i=0; i<state->num_reqs; i++) { 468 if (state->reqs[i].req == read_req) { 469 break; 470 } 471 } 472 473 if (i == state->num_reqs) { 474 /* Got something we did not send. Just drop it. */ 475 TALLOC_FREE(read_req); 476 return; 477 } 478 479 state->reqs[i].received = received; 480 state->reqs[i].buf = buf; 332 481 333 482 /* … … 340 489 */ 341 490 342 while (state->reqs[state->top_req] != NULL) {343 struct cli_ request*top_read;491 while (state->reqs[state->top_req].req != NULL) { 492 struct cli_pull_subreq *top_read; 344 493 345 494 DEBUG(11, ("cli_pull_read_done: top_req = %d\n", 346 495 state->top_req)); 347 496 348 if (state->reqs[state->top_req] ->state < ASYNC_REQ_DONE) {497 if (state->reqs[state->top_req].req->state < ASYNC_REQ_DONE) { 349 498 DEBUG(11, ("cli_pull_read_done: top request not yet " 350 499 "done\n")); … … 352 501 } 353 502 354 top_read = cli_request_get(state->reqs[state->top_req]);503 top_read = &state->reqs[state->top_req]; 355 504 356 505 DEBUG(10, ("cli_pull_read_done: Pushing %d bytes, %d already " 357 "pushed\n", (int)top_read-> data.read.received,506 "pushed\n", (int)top_read->received, 358 507 (int)state->pushed)); 359 508 360 status = state->sink((char *)top_read->data.read.rcvbuf, 361 top_read->data.read.received, 509 status = state->sink((char *)top_read->buf, top_read->received, 362 510 state->priv); 363 511 if (!NT_STATUS_IS_OK(status)) { … … 365 513 return; 366 514 } 367 state->pushed += top_read-> data.read.received;368 369 TALLOC_FREE(state->reqs[state->top_req] );515 state->pushed += top_read->received; 516 517 TALLOC_FREE(state->reqs[state->top_req].req); 370 518 371 519 if (state->requested < state->size) { … … 384 532 state->top_req)); 385 533 386 new_req = cli_read _andx_send(534 new_req = cli_readall_send( 387 535 state->reqs, state->cli, state->fnum, 388 536 state->start_offset + state->requested, … … 396 544 new_req->async.priv = pull_req; 397 545 398 state->reqs[state->top_req] = new_req;546 state->reqs[state->top_req].req = new_req; 399 547 state->requested += request_thistime; 400 548 } -
branches/samba-3.3.x/source/libsmb/dsgetdcname.c
r223 r342 627 627 struct ip_service_name *r = &dclist[count]; 628 628 629 r->port = dcs[ count].port;630 r->hostname = dcs[ count].hostname;629 r->port = dcs[i].port; 630 r->hostname = dcs[i].hostname; 631 631 632 632 /* If we don't have an IP list for a name, lookup it up */ -
branches/samba-3.3.x/source/libsmb/libsmb_context.c
r222 r342 656 656 const char *signing_state = "off"; 657 657 658 if (!context || 659 ! workgroup || ! *workgroup || 660 ! user || ! *user || 661 ! password || ! *password) { 658 if (! context) { 662 659 663 660 return; 664 661 } 665 662 663 if (! workgroup || ! *workgroup) { 664 workgroup = smbc_getWorkgroup(context); 665 } 666 667 if (! user) { 668 user = smbc_getUser(context); 669 } 670 671 if (! password) { 672 password = ""; 673 } 674 666 675 if (smbc_getOptionUseKerberos(context)) { 667 676 use_kerberos = True; -
branches/samba-3.3.x/source/libsmb/libsmb_dir.c
r223 r342 626 626 * Get the backup list ... 627 627 */ 628 if (!name_status_find(server, 0 ,0,628 if (!name_status_find(server, 0x20, 0x20, 629 629 &rem_ss, buserver)) { 630 630 -
branches/samba-3.3.x/source/libsmb/namequery.c
r221 r342 409 409 410 410 for (i=0;i<count;i++) { 411 if (status[i].type == type) 411 /* Find first one of the requested type that's not a GROUP. */ 412 if (status[i].type == type && ! (status[i].flags & 0x80)) 412 413 break; 413 414 } -
branches/samba-3.3.x/source/libsmb/passchange.c
r309 r342 153 153 result = cli_rpc_pipe_open_ntlmssp(cli, 154 154 &ndr_table_samr.syntax_id, 155 NCACN_NP, 155 156 PIPE_AUTH_LEVEL_PRIVACY, 156 157 "", /* what domain... ? */
Note:
See TracChangeset
for help on using the changeset viewer.