SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);
SSLerr(SSL_F_DTLS1_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);
int dtls1_client_hello(SSL *s)	{	unsigned char *buf;	unsigned char *p,*d;	int i,j;	unsigned long Time,l;	SSL_COMP *comp;	buf=(unsigned char *)s->init_buf->data;	if (s->state == SSL3_ST_CW_CLNT_HELLO_A)		{		if ((s->session == NULL) ||			(s->session->ssl_version != s->version) ||			(s->session->not_resumable))			{			if (!ssl_get_new_session(s,0))				goto err;			}		/* else use the pre-loaded session */		p=s->s3->client_random;		Time=time(NULL);			/* Time */		l2n(Time,p);		RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));		/* Do the message type and length last */		d=p= &(buf[DTLS1_HM_HEADER_LENGTH]);		*(p++)=s->version>>8;		*(p++)=s->version&0xff;		s->client_version=s->version;		/* Random stuff */		memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE);		p+=SSL3_RANDOM_SIZE;		/* Session ID */		if (s->new_session)			i=0;		else			i=s->session->session_id_length;		*(p++)=i;		if (i != 0)			{			if (i > sizeof s->session->session_id)				{				SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);				goto err;				}			memcpy(p,s->session->session_id,i);			p+=i;			}				/* cookie stuff */		if ( s->d1->cookie_len > sizeof(s->d1->cookie))			{			SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);			goto err;			}		*(p++) = s->d1->cookie_len;		memcpy(p, s->d1->cookie, s->d1->cookie_len);		p += s->d1->cookie_len;		/* Ciphers supported */		i=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),&(p[2]));		if (i == 0)			{			SSLerr(SSL_F_SSL3_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);			goto err;			}		s2n(i,p);		p+=i;		/* COMPRESSION */		if (s->ctx->comp_methods == NULL)			j=0;		else			j=sk_SSL_COMP_num(s->ctx->comp_methods);		*(p++)=1+j;		for (i=0; i<j; i++)			{			comp=sk_SSL_COMP_value(s->ctx->comp_methods,i);			*(p++)=comp->id;			}		*(p++)=0; /* Add the NULL method */				l=(p-d);		d=buf;		d = dtls1_set_message_header(s, d, SSL3_MT_CLIENT_HELLO, l, 0, l);		s->state=SSL3_ST_CW_CLNT_HELLO_B;		/* number of bytes to write */		s->init_num=p-buf;		s->init_off=0;		/* buffer the message to handle re-xmits */		dtls1_buffer_message(s, 0);		}	/* SSL3_ST_CW_CLNT_HELLO_B */	return(dtls1_do_write(s,SSL3_RT_HANDSHAKE));err:	return(-1);	}