rdata = (DTLS1_RECORD_DATA *)item->data;
- SSL3_BUFFER_release(RECORD_LAYER_get_rbuf(&s->rlayer));
+ SSL3_BUFFER_release(&s->rlayer.rbuf);
s->packet = rdata->packet;
s->packet_length = rdata->packet_length;
- memcpy(RECORD_LAYER_get_rbuf(&s->rlayer), &(rdata->rbuf),
- sizeof(SSL3_BUFFER));
- memcpy(RECORD_LAYER_get_rrec(&s->rlayer), &(rdata->rrec),
- sizeof(SSL3_RECORD));
+ memcpy(&s->rlayer.rbuf, &(rdata->rbuf), sizeof(SSL3_BUFFER));
+ memcpy(&s->rlayer.rrec, &(rdata->rrec), sizeof(SSL3_RECORD));
/* Set proper sequence number for mac calculation */
memcpy(&(s->s3->read_sequence[2]), &(rdata->packet[5]), 6);
rdata->packet = s->packet;
rdata->packet_length = s->packet_length;
- memcpy(&(rdata->rbuf), RECORD_LAYER_get_rbuf(&s->rlayer),
- sizeof(SSL3_BUFFER));
- memcpy(&(rdata->rrec), RECORD_LAYER_get_rrec(&s->rlayer),
- sizeof(SSL3_RECORD));
+ memcpy(&(rdata->rbuf), &s->rlayer.rbuf, sizeof(SSL3_BUFFER));
+ memcpy(&(rdata->rrec), &s->rlayer.rrec, sizeof(SSL3_RECORD));
item->data = rdata;
s->packet = NULL;
s->packet_length = 0;
- memset(RECORD_LAYER_get_rbuf(&s->rlayer), 0, sizeof(SSL3_BUFFER));
- memset(RECORD_LAYER_get_rrec(&s->rlayer), 0, sizeof(SSL3_RECORD));
+ memset(&s->rlayer.rbuf, 0, sizeof(SSL3_BUFFER));
+ memset(&s->rlayer.rrec, 0, sizeof(SSL3_RECORD));
if (!ssl3_setup_buffers(s)) {
SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);
if (!dtls1_process_record(s))
return (0);
if (dtls1_buffer_record(s, &(s->d1->processed_rcds),
- SSL3_RECORD_get_seq_num(RECORD_LAYER_get_rrec(&s->rlayer))) < 0)
+ SSL3_RECORD_get_seq_num(&s->rlayer.rrec)) < 0)
return -1;
}
}
SSL3_RECORD *rr;
void (*cb) (const SSL *ssl, int type2, int val) = NULL;
- if (!SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer))) {
+ if (!SSL3_BUFFER_is_initialised(&s->rlayer.rbuf)) {
/* Not initialized yet */
if (!ssl3_setup_buffers(s))
return (-1);
* s->s3->rrec.off, - offset into 'data' for next read
* s->s3->rrec.length, - number of bytes.
*/
- rr = RECORD_LAYER_get_rrec(&s->rlayer);
+ rr = &s->rlayer.rrec;
/*
* We are not handshaking and have no data yet, so process data buffered
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (SSL3_BUFFER_get_left(
- RECORD_LAYER_get_rbuf(&s->rlayer)) == 0) {
+ if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {
/* no read-ahead left? */
BIO *bio;
/*
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (SSL3_BUFFER_get_left(
- RECORD_LAYER_get_rbuf(&s->rlayer)) == 0) {
+ if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {
/* no read-ahead left? */
BIO *bio;
/*
SSL3_BUFFER *wb;
SSL_SESSION *sess;
- wb = RECORD_LAYER_get_wbuf(&s->rlayer);
+ wb = &s->rlayer.wbuf;
/*
* first check if there is a SSL3_BUFFER still being written out. This
if (len == 0 && !create_empty_fragment)
return 0;
- wr = RECORD_LAYER_get_wrec(&s->rlayer);
+ wr = &s->rlayer.wrec;
sess = s->session;
if ((sess == NULL) ||
cmp = satsub64be(seq, bitmap->max_seq_num);
if (cmp > 0) {
- SSL3_RECORD_set_seq_num(RECORD_LAYER_get_rrec(&s->rlayer), seq);
+ SSL3_RECORD_set_seq_num(&s->rlayer.rrec, seq);
return 1; /* this record in new */
}
shift = -cmp;
else if (bitmap->map & (1UL << shift))
return 0; /* record previously received */
- SSL3_RECORD_set_seq_num(RECORD_LAYER_get_rrec(&s->rlayer), seq);
+ SSL3_RECORD_set_seq_num(&s->rlayer.rrec, seq);
return 1;
}
#define RECORD_LAYER_set_read_ahead(rl, ra) ((rl)->read_ahead = (ra))
#define RECORD_LAYER_get_read_ahead(rl) ((rl)->read_ahead)
-#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
-#define RECORD_LAYER_get_wbuf(rl) (&(rl)->wbuf)
-#define RECORD_LAYER_get_rrec(rl) (&(rl)->rrec)
-#define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec)
#define RECORD_LAYER_setup_comp_buffer(rl) (SSL3_RECORD_setup(&(rl)->rrec))
void RECORD_LAYER_init(RECORD_LAYER *rl, SSL *s);
/*****************************************************************************
* *
- * The following functions are private to the record layer. They should not *
- * be used outside of the record layer. *
+ * The following macros/functions are private to the record layer. They *
+ * should not be used outside of the record layer. *
* *
*****************************************************************************/
+#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
+#define RECORD_LAYER_get_wbuf(rl) (&(rl)->wbuf)
+#define RECORD_LAYER_get_rrec(rl) (&(rl)->rrec)
+#define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec)
+
__owur int ssl3_read_n(SSL *s, int n, int max, int extend);
__owur int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
unsigned int len);
if (n <= 0)
return n;
- rb = RECORD_LAYER_get_rbuf(&s->rlayer);
+ rb = &s->rlayer.rbuf;
if (rb->buf == NULL)
if (!ssl3_setup_read_buffer(s))
return -1;
#if !defined(OPENSSL_NO_MULTIBLOCK) && EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK
unsigned int max_send_fragment;
#endif
- SSL3_BUFFER *wb = RECORD_LAYER_get_wbuf(&s->rlayer);
+ SSL3_BUFFER *wb = &s->rlayer.wbuf;
int i;
unsigned int u_len = (unsigned int)len;
int eivlen;
long align = 0;
SSL3_RECORD *wr;
- SSL3_BUFFER *wb = RECORD_LAYER_get_wbuf(&s->rlayer);
+ SSL3_BUFFER *wb = &s->rlayer.wbuf;
SSL_SESSION *sess;
/*
if (len == 0 && !create_empty_fragment)
return 0;
- wr = RECORD_LAYER_get_wrec(&s->rlayer);
+ wr = &s->rlayer.wrec;
sess = s->session;
if ((sess == NULL) ||
unsigned int len)
{
int i;
- SSL3_BUFFER *wb = RECORD_LAYER_get_wbuf(&s->rlayer);
+ SSL3_BUFFER *wb = &s->rlayer.wbuf;
/* XXXX */
if ((s->s3->wpend_tot > (int)len)
SSL3_RECORD *rr;
void (*cb) (const SSL *ssl, int type2, int val) = NULL;
- if (!SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer))) {
+ if (!SSL3_BUFFER_is_initialised(&s->rlayer.rbuf)) {
/* Not initialized yet */
if (!ssl3_setup_read_buffer(s))
return (-1);
* s->s3->rrec.off, - offset into 'data' for next read
* s->s3->rrec.length, - number of bytes.
*/
- rr = RECORD_LAYER_get_rrec(&s->rlayer);
+ rr = &s->rlayer.rrec;
/* get new packet if necessary */
if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) {
s->rstate = SSL_ST_READ_HEADER;
rr->off = 0;
if (s->mode & SSL_MODE_RELEASE_BUFFERS
- && SSL3_BUFFER_get_left(
- RECORD_LAYER_get_rbuf(&s->rlayer)) == 0)
+ && SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0)
ssl3_release_read_buffer(s);
}
}
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (SSL3_BUFFER_get_left(
- RECORD_LAYER_get_rbuf(&s->rlayer)) == 0) {
+ if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {
/* no read-ahead left? */
BIO *bio;
/*
}
if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
- if (SSL3_BUFFER_get_left(RECORD_LAYER_get_rbuf(&s->rlayer)) == 0) {
+ if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {
/* no read-ahead left? */
BIO *bio;
/*
if ((s->rstate != SSL_ST_READ_BODY) ||
(s->packet_length < SSL3_RT_HEADER_LENGTH)) {
n = ssl3_read_n(s, SSL3_RT_HEADER_LENGTH,
- SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer)), 0);
+ SSL3_BUFFER_get_len(&s->rlayer.rbuf), 0);
if (n <= 0)
return (n); /* error or non-blocking */
s->rstate = SSL_ST_READ_BODY;
}
if (rr->length >
- SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer))
+ SSL3_BUFFER_get_len(&s->rlayer.rbuf)
- SSL3_RT_HEADER_LENGTH) {
al = SSL_AD_RECORD_OVERFLOW;
SSLerr(SSL_F_SSL3_GET_RECORD, SSL_R_PACKET_LENGTH_TOO_LONG);
if ((s->rstate != SSL_ST_READ_BODY) ||
(s->packet_length < DTLS1_RT_HEADER_LENGTH)) {
n = ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH,
- SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer)), 0);
+ SSL3_BUFFER_get_len(&s->rlayer.rbuf), 0);
/* read timeout is handled by dtls1_read_bytes */
if (n <= 0)
return (n); /* error or non-blocking */