static int mtu_test(SSL_CTX *ctx, const char *cs, int no_etm)
{
    SSL *srvr_ssl = NULL, *clnt_ssl = NULL;
    BIO *sc_bio = NULL;
    int i;
    size_t s;
    size_t mtus[30];
    unsigned char buf[600];
    int rv = 0;
    memset(buf, 0x5a, sizeof(buf));
    if (create_ssl_objects(ctx, ctx, &srvr_ssl, &clnt_ssl, NULL, NULL) != 1)
        goto out;
    if (no_etm)
        SSL_set_options(srvr_ssl, SSL_OP_NO_ENCRYPT_THEN_MAC);
    if (SSL_set_cipher_list(srvr_ssl, cs) != 1 ||
        SSL_set_cipher_list(clnt_ssl, cs) != 1) {
        ERR_print_errors_fp(stdout);
        goto out;
    }
    sc_bio = SSL_get_rbio(srvr_ssl);
    if (create_ssl_connection(clnt_ssl, srvr_ssl) != 1)
        goto out;
    if (debug)
        printf("Channel established\n");
    for (i = 0; i < 30; i++) {
        SSL_set_mtu(clnt_ssl, 500 + i);
        mtus[i] = DTLS_get_data_mtu(clnt_ssl);
        if (debug)
            printf("%s%s payload MTU for record mtu %d = %"OSSLzu"\n",
                   cs, no_etm ? "-noEtM":"", 500 + i, mtus[i]);
        if (mtus[i] == 0) {
            fprintf(stderr,
                    "payload MTU failed with record MTU %d for %s\n",
                    500 + i, cs);
            goto out;
        }
    }
    SSL_set_mtu(clnt_ssl, 1000);
    for (s = mtus[0]; s <= mtus[29]; s++) {
        size_t reclen;
        if (SSL_write(clnt_ssl, buf, s) != (int)s) {
            ERR_print_errors_fp(stdout);
            goto out;
        }
        reclen = BIO_read(sc_bio, buf, sizeof(buf));
        if (debug)
            printf("record %"OSSLzu" for payload %"OSSLzu"\n", reclen, s);
        for (i = 0; i < 30; i++) {
            if (s <= mtus[i] && reclen > (size_t)(500 + i)) {
                fprintf(stderr,
                        "%s: Payload MTU %"OSSLzu" reported for record MTU %d\n"
                        "but sending a payload of %"OSSLzu" made a record of %"OSSLzu"(too large)\n",
                        cs, mtus[i], 500 + i, s, reclen);
                goto out;
            }
            if (s > mtus[i] && reclen <= (size_t)(500 + i)) {
                fprintf(stderr,
                        "%s: Payload MTU %"OSSLzu" reported for record MTU %d\n"
                        "but sending a payload of %"OSSLzu" made a record of %"OSSLzu" (too small)\n",
                        cs, mtus[i], 500 + i, s, reclen);
                goto out;
            }
        }
    }
    rv = 1;
    if (SSL_USE_ETM(clnt_ssl))
        rv = 2;
 out:
    SSL_free(clnt_ssl);
    SSL_free(srvr_ssl);
    return rv;
}
['static int mtu_test(SSL_CTX *ctx, const char *cs, int no_etm)\n{\n    SSL *srvr_ssl = NULL, *clnt_ssl = NULL;\n    BIO *sc_bio = NULL;\n    int i;\n    size_t s;\n    size_t mtus[30];\n    unsigned char buf[600];\n    int rv = 0;\n    memset(buf, 0x5a, sizeof(buf));\n    if (create_ssl_objects(ctx, ctx, &srvr_ssl, &clnt_ssl, NULL, NULL) != 1)\n        goto out;\n    if (no_etm)\n        SSL_set_options(srvr_ssl, SSL_OP_NO_ENCRYPT_THEN_MAC);\n    if (SSL_set_cipher_list(srvr_ssl, cs) != 1 ||\n        SSL_set_cipher_list(clnt_ssl, cs) != 1) {\n        ERR_print_errors_fp(stdout);\n        goto out;\n    }\n    sc_bio = SSL_get_rbio(srvr_ssl);\n    if (create_ssl_connection(clnt_ssl, srvr_ssl) != 1)\n        goto out;\n    if (debug)\n        printf("Channel established\\n");\n    for (i = 0; i < 30; i++) {\n        SSL_set_mtu(clnt_ssl, 500 + i);\n        mtus[i] = DTLS_get_data_mtu(clnt_ssl);\n        if (debug)\n            printf("%s%s payload MTU for record mtu %d = %"OSSLzu"\\n",\n                   cs, no_etm ? "-noEtM":"", 500 + i, mtus[i]);\n        if (mtus[i] == 0) {\n            fprintf(stderr,\n                    "payload MTU failed with record MTU %d for %s\\n",\n                    500 + i, cs);\n            goto out;\n        }\n    }\n    SSL_set_mtu(clnt_ssl, 1000);\n    for (s = mtus[0]; s <= mtus[29]; s++) {\n        size_t reclen;\n        if (SSL_write(clnt_ssl, buf, s) != (int)s) {\n            ERR_print_errors_fp(stdout);\n            goto out;\n        }\n        reclen = BIO_read(sc_bio, buf, sizeof(buf));\n        if (debug)\n            printf("record %"OSSLzu" for payload %"OSSLzu"\\n", reclen, s);\n        for (i = 0; i < 30; i++) {\n            if (s <= mtus[i] && reclen > (size_t)(500 + i)) {\n                fprintf(stderr,\n                        "%s: Payload MTU %"OSSLzu" reported for record MTU %d\\n"\n                        "but sending a payload of %"OSSLzu" made a record of %"OSSLzu"(too large)\\n",\n                        cs, mtus[i], 500 + i, s, reclen);\n                goto out;\n            }\n            if (s > mtus[i] && reclen <= (size_t)(500 + i)) {\n                fprintf(stderr,\n                        "%s: Payload MTU %"OSSLzu" reported for record MTU %d\\n"\n                        "but sending a payload of %"OSSLzu" made a record of %"OSSLzu" (too small)\\n",\n                        cs, mtus[i], 500 + i, s, reclen);\n                goto out;\n            }\n        }\n    }\n    rv = 1;\n    if (SSL_USE_ETM(clnt_ssl))\n        rv = 2;\n out:\n    SSL_free(clnt_ssl);\n    SSL_free(srvr_ssl);\n    return rv;\n}']