- if ($c_min > $c_max) {
- # Client should fail to even send a hello.
- # This results in an internal error since the server will be
- # waiting for input that never arrives.
- return ("InternalError", undef);
- } elsif ($s_min > $s_max) {
- # Server has no protocols, should always fail.
- return ("ServerFail", undef);
- } elsif ($s_min > $c_max) {
- # Server doesn't support the client range.
- return ("ServerFail", undef);
- } elsif ($c_min > $s_max) {
- # Server will try with a version that is lower than the lowest
- # supported client version.
- return ("ClientFail", undef);
- } else {
- # Server and client ranges overlap.
- my $max_common = $s_max < $c_max ? $s_max : $c_max;
- return ("Success", $protocols[$max_common]);
- }
-}