src/payload.c
static int
smp_fetch_ssl_hello_type(struct proxy *px, struct session *s, void *l7, unsigned int opt,
                         const struct arg *args, struct sample *smp)
{
	int hs_len;
	int hs_type, bleft;
	struct channel *chn;
	const unsigned char *data;

	if (!s)
		goto not_ssl_hello;

	chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? s->rep : s->req;

	bleft = chn->buf->i;
	data = (const unsigned char *)chn->buf->p;

	if (!bleft)
		goto too_short;

	if ((*data >= 0x14 && *data <= 0x17) || (*data == 0xFF)) {
		/* SSLv3 header format */
		if (bleft < 9)
			goto too_short;

		/* ssl version 3 */
		if ((data[1] << 16) + data[2] < 0x00030000)
			goto not_ssl_hello;

		/* ssl message len must present handshake type and len */
		if ((data[3] << 8) + data[4] < 4)
			goto not_ssl_hello;

		/* format introduced with SSLv3 */

		hs_type = (int)data[5];
		hs_len = ( data[6] << 16 ) + ( data[7] << 8 ) + data[8];

		/* not a full handshake */
		if (bleft < (9 + hs_len))
			goto too_short;

	}
	else {
		goto not_ssl_hello;
	}

	smp->type = SMP_T_UINT;
	smp->data.uint = hs_type;
	smp->flags = SMP_F_VOLATILE;

	return 1;

 too_short:
	smp->flags = SMP_F_MAY_CHANGE;

 not_ssl_hello:

	return 0;
}
/* returns the type of SSL hello message (mainly used to detect an SSL hello) */
returns the type of SSL hello message (mainly used to detect an SSL hello)
returns the type of SSL hello message ( mainly used to detect an SSL hello )
static int
smp_fetch_ssl_hello_type(struct proxy *px, struct session *s, void *l7, unsigned int opt,
                         const struct arg *args, struct sample *smp)
{
	int hs_len;
	int hs_type, bleft;
	struct channel *chn;
	const unsigned char *data;
	if (!s)
		goto not_ssl_hello;
	chn = ((opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ? s->rep : s->req;
	bleft = chn->buf->i;
	data = (const unsigned char *)chn->buf->p;
	if (!bleft)
		goto too_short;
	if ((*data >= 0x14 && *data <= 0x17) || (*data == 0xFF)) {
		if (bleft < 9)
			goto too_short;
		if ((data[1] << 16) + data[2] < 0x00030000)
			goto not_ssl_hello;
		if ((data[3] << 8) + data[4] < 4)
			goto not_ssl_hello;
		hs_type = (int)data[5];
		hs_len = ( data[6] << 16 ) + ( data[7] << 8 ) + data[8];
		if (bleft < (9 + hs_len))
			goto too_short;
	}
	else {
		goto not_ssl_hello;
	}
	smp->type = SMP_T_UINT;
	smp->data.uint = hs_type;
	smp->flags = SMP_F_VOLATILE;
	return 1;
 too_short:
	smp->flags = SMP_F_MAY_CHANGE;
 not_ssl_hello:
	return 0;
}
static int smp_fetch_ssl_hello_type ( struct proxy * px , struct session * s , void * l7 , unsigned int opt , const struct arg * args , struct sample * smp ) { int hs_len ; int hs_type , bleft ; struct channel * chn ; const unsigned char * data ; if ( ! s ) goto not_ssl_hello ; chn = ( ( opt & SMP_OPT_DIR ) == SMP_OPT_DIR_RES ) ? s -> rep : s -> req ; bleft = chn -> buf -> i ; data = ( const unsigned char * ) chn -> buf -> p ; if ( ! bleft ) goto too_short ; if ( ( * data >= 0x14 && * data <= 0x17 ) || ( * data == 0xFF ) ) { if ( bleft < 9 ) goto too_short ; if ( ( data [ 1 ] << 16 ) + data [ 2 ] < 0x00030000 ) goto not_ssl_hello ; if ( ( data [ 3 ] << 8 ) + data [ 4 ] < 4 ) goto not_ssl_hello ; hs_type = ( int ) data [ 5 ] ; hs_len = ( data [ 6 ] << 16 ) + ( data [ 7 ] << 8 ) + data [ 8 ] ; if ( bleft < ( 9 + hs_len ) ) goto too_short ; } else { goto not_ssl_hello ; } smp -> type = SMP_T_UINT ; smp -> data . uint = hs_type ; smp -> flags = SMP_F_VOLATILE ; return 1 ; too_short : smp -> flags = SMP_F_MAY_CHANGE ; not_ssl_hello : return 0 ; }
returns the type of SSL hello message (mainly used to detect an SSL hello)
returns the type of SSL hello message ( mainly used to detect an SSL hello )
/* SSLv3 header format */ /* ssl version 3 */ /* ssl message len must present handshake type and len */ /* format introduced with SSLv3 */ /* not a full handshake */