| 533 | } |
| 534 | |
| 535 | static void negotiate_the_strings(int f_in, int f_out) |
| 536 | { |
| 537 | /* We send all the negotiation strings before we start to read them to help avoid a slow startup. */ |
| 538 | |
| 539 | init_checksum_choices(); |
| 540 | |
| 541 | if (!checksum_choice) |
| 542 | send_negotiate_str(f_out, &valid_checksums, NSTR_CHECKSUM); |
| 543 | |
| 544 | if (do_compression && !compress_choice) |
| 545 | send_negotiate_str(f_out, &valid_compressions, NSTR_COMPRESS); |
| 546 | |
| 547 | if (valid_checksums.saw) { |
| 548 | char tmpbuf[MAX_NSTR_STRLEN]; |
| 549 | int len; |
| 550 | if (do_negotiated_strings) |
| 551 | len = -1; |
| 552 | else |
| 553 | len = strlcpy(tmpbuf, protocol_version >= 30 ? "md5" : "md4", MAX_NSTR_STRLEN); |
| 554 | recv_negotiate_str(f_in, &valid_checksums, tmpbuf, len); |
| 555 | } |
| 556 | |
| 557 | if (valid_compressions.saw) { |
| 558 | char tmpbuf[MAX_NSTR_STRLEN]; |
| 559 | int len; |
| 560 | if (do_negotiated_strings) |
| 561 | len = -1; |
| 562 | else |
| 563 | len = strlcpy(tmpbuf, "zlib", MAX_NSTR_STRLEN); |
| 564 | recv_negotiate_str(f_in, &valid_compressions, tmpbuf, len); |
| 565 | } |
| 566 | |
| 567 | /* If the other side is too old to negotiate, the above steps just made sure that |
| 568 | * the env didn't disallow the old algorithm. Mark things as non-negotiated. */ |
| 569 | if (!do_negotiated_strings) |
| 570 | valid_checksums.negotiated_nni = valid_compressions.negotiated_nni = NULL; |
| 571 | } |
| 572 | |
| 573 | void setup_protocol(int f_out,int f_in) |
| 574 | { |
no test coverage detected