openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libvncserver/0.9.12+gitAUTOINC+c0a23857a5-r0/git/libvncserver/websockets.c
rfbBool webSocketsCheck(rfbClientPtr cl)
{
    char bbuf[4], *scheme;
    int ret;

    ret = rfbPeekExactTimeout(cl, bbuf, 4, WEBSOCKETS_CLIENT_CONNECT_WAIT_MS);
    if ((ret < 0) && (errno == ETIMEDOUT))
    {
        rfbLog("Normal socket connection\n");
        return TRUE;
    }
    else if (ret <= 0)
    {
        rfbErr("webSocketsHandshake: unknown connection error\n");
        return FALSE;
    }

    if (strncmp(bbuf, "RFB ", 4) == 0)
    {
        rfbLog("Normal socket connection\n");
        return TRUE;
    }
    else if (strncmp(bbuf, "\x16", 1) == 0 || strncmp(bbuf, "\x80", 1) == 0)
    {
        rfbLog("Got TLS/SSL WebSockets connection\n");
        if (-1 == rfbssl_init(cl))
        {
            rfbErr("webSocketsHandshake: rfbssl_init failed\n");
            return FALSE;
        }
        ret =
            rfbPeekExactTimeout(cl, bbuf, 4, WEBSOCKETS_CLIENT_CONNECT_WAIT_MS);
        scheme = "wss";
    }
    else
    {
        scheme = "ws";
    }

    if (strncmp(bbuf, "GET ", 4) != 0)
    {
        rfbErr("webSocketsHandshake: invalid client header\n");
        return FALSE;
    }

    rfbLog("Got '%s' WebSockets handshake\n", scheme);

    if (!webSocketsHandshake(cl, scheme))
    {
        return FALSE;
    }
    /* Start WebSockets framing */
    return TRUE;
}
/*
 * rfbWebSocketsHandshake is called to handle new WebSockets connections
 */
rfbWebSocketsHandshake is called to handle new WebSockets connections
rfbWebSocketsHandshake is called to handle new WebSockets connections
rfbBool webSocketsCheck(rfbClientPtr cl)
{
    char bbuf[4], *scheme;
    int ret;
    ret = rfbPeekExactTimeout(cl, bbuf, 4, WEBSOCKETS_CLIENT_CONNECT_WAIT_MS);
    if ((ret < 0) && (errno == ETIMEDOUT))
    {
        rfbLog("Normal socket connection\n");
        return TRUE;
    }
    else if (ret <= 0)
    {
        rfbErr("webSocketsHandshake: unknown connection error\n");
        return FALSE;
    }
    if (strncmp(bbuf, "RFB ", 4) == 0)
    {
        rfbLog("Normal socket connection\n");
        return TRUE;
    }
    else if (strncmp(bbuf, "\x16", 1) == 0 || strncmp(bbuf, "\x80", 1) == 0)
    {
        rfbLog("Got TLS/SSL WebSockets connection\n");
        if (-1 == rfbssl_init(cl))
        {
            rfbErr("webSocketsHandshake: rfbssl_init failed\n");
            return FALSE;
        }
        ret =
            rfbPeekExactTimeout(cl, bbuf, 4, WEBSOCKETS_CLIENT_CONNECT_WAIT_MS);
        scheme = "wss";
    }
    else
    {
        scheme = "ws";
    }
    if (strncmp(bbuf, "GET ", 4) != 0)
    {
        rfbErr("webSocketsHandshake: invalid client header\n");
        return FALSE;
    }
    rfbLog("Got '%s' WebSockets handshake\n", scheme);
    if (!webSocketsHandshake(cl, scheme))
    {
        return FALSE;
    }
    return TRUE;
}
rfbBool webSocketsCheck ( rfbClientPtr cl ) { char bbuf [ 4 ] , * scheme ; int ret ; ret = rfbPeekExactTimeout ( cl , bbuf , 4 , WEBSOCKETS_CLIENT_CONNECT_WAIT_MS ) ; if ( ( ret < 0 ) && ( errno == ETIMEDOUT ) ) { rfbLog ( " \n " ) ; return TRUE ; } else if ( ret <= 0 ) { rfbErr ( " \n " ) ; return FALSE ; } if ( strncmp ( bbuf , " " , 4 ) == 0 ) { rfbLog ( " \n " ) ; return TRUE ; } else if ( strncmp ( bbuf , " \x16 " , 1 ) == 0 || strncmp ( bbuf , " \x80 " , 1 ) == 0 ) { rfbLog ( " \n " ) ; if ( -1 == rfbssl_init ( cl ) ) { rfbErr ( " \n " ) ; return FALSE ; } ret = rfbPeekExactTimeout ( cl , bbuf , 4 , WEBSOCKETS_CLIENT_CONNECT_WAIT_MS ) ; scheme = " " ; } else { scheme = " " ; } if ( strncmp ( bbuf , " " , 4 ) != 0 ) { rfbErr ( " \n " ) ; return FALSE ; } rfbLog ( " \n " , scheme ) ; if ( ! webSocketsHandshake ( cl , scheme ) ) { return FALSE ; } return TRUE ; }
rfbWebSocketsHandshake is called to handle new WebSockets connections
rfbWebSocketsHandshake is called to handle new WebSockets connections
/* Start WebSockets framing */