Fold dtls1_set_message_header into dtls1_set_handshake_header.

The frag_off/frag_len parameters are always zero, and the return value is never
used.

Change-Id: If7487b23c55f2a996e411b25b76a8e1651f25d8b
Reviewed-on: https://boringssl-review.googlesource.com/2601
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index dec9bc4..655a0fc 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -170,11 +170,6 @@
 static void dtls1_fix_message_header(SSL *s, unsigned long frag_off,
                                      unsigned long frag_len);
 static unsigned char *dtls1_write_message_header(SSL *s, unsigned char *p);
-static void dtls1_set_message_header_int(SSL *s, unsigned char mt,
-                                         unsigned long len,
-                                         unsigned short seq_num,
-                                         unsigned long frag_off,
-                                         unsigned long frag_len);
 static long dtls1_get_message_fragment(SSL *s, int stn, long max, int *ok);
 
 static hm_fragment *dtls1_hm_fragment_new(unsigned long frag_len,
@@ -909,8 +904,8 @@
 
     s->init_off = 0;
 
-    dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, s->d1->handshake_write_seq,
-                                 0, 0);
+    dtls1_set_message_header(s, SSL3_MT_CCS, 0, s->d1->handshake_write_seq, 0,
+                             0);
 
     /* buffer the message to handle re-xmits */
     dtls1_buffer_message(s, 1);
@@ -1073,9 +1068,9 @@
          frag->msg_header.msg_len + header_length);
   s->init_num = frag->msg_header.msg_len + header_length;
 
-  dtls1_set_message_header_int(s, frag->msg_header.type,
-                               frag->msg_header.msg_len, frag->msg_header.seq,
-                               0, frag->msg_header.frag_len);
+  dtls1_set_message_header(s, frag->msg_header.type,
+                           frag->msg_header.msg_len, frag->msg_header.seq,
+                           0, frag->msg_header.frag_len);
 
   /* save current state */
   saved_state.enc_write_ctx = s->enc_write_ctx;
@@ -1132,25 +1127,10 @@
   }
 }
 
-uint8_t *dtls1_set_message_header(SSL *s, uint8_t *p, uint8_t mt,
-                                  unsigned long len, unsigned long frag_off,
-                                  unsigned long frag_len) {
-  if (frag_off == 0) {
-    s->d1->handshake_write_seq = s->d1->next_handshake_write_seq;
-    s->d1->next_handshake_write_seq++;
-  }
-
-  dtls1_set_message_header_int(s, mt, len, s->d1->handshake_write_seq, frag_off,
-                               frag_len);
-
-  return p += DTLS1_HM_HEADER_LENGTH;
-}
-
 /* don't actually do the writing, wait till the MTU has been retrieved */
-static void dtls1_set_message_header_int(SSL *s, uint8_t mt, unsigned long len,
-                                         unsigned short seq_num,
-                                         unsigned long frag_off,
-                                         unsigned long frag_len) {
+void dtls1_set_message_header(SSL *s, uint8_t mt, unsigned long len,
+                              unsigned short seq_num, unsigned long frag_off,
+                              unsigned long frag_len) {
   struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr;
 
   msg_hdr->type = mt;
diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c
index 1de75b8..f058036 100644
--- a/ssl/d1_lib.c
+++ b/ssl/d1_lib.c
@@ -448,10 +448,13 @@
 }
 
 static void dtls1_set_handshake_header(SSL *s, int htype, unsigned long len) {
-  uint8_t *p = (uint8_t *)s->init_buf->data;
-  dtls1_set_message_header(s, p, htype, len, 0, len);
+  s->d1->handshake_write_seq = s->d1->next_handshake_write_seq;
+  s->d1->next_handshake_write_seq++;
+
+  dtls1_set_message_header(s, htype, len, s->d1->handshake_write_seq, 0, len);
   s->init_num = (int)len + DTLS1_HM_HEADER_LENGTH;
   s->init_off = 0;
+
   /* Buffer the message to handle re-xmits */
   dtls1_buffer_message(s, 0);
 }
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index 6d8276a..8522375 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -836,9 +836,8 @@
 int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
 int ssl3_write_pending(SSL *s, int type, const unsigned char *buf,
 	unsigned int len);
-unsigned char *dtls1_set_message_header(SSL *s, 
-	unsigned char *p, unsigned char mt,	unsigned long len, 
-	unsigned long frag_off, unsigned long frag_len);
+void dtls1_set_message_header(SSL *s, uint8_t mt, unsigned long len,
+	unsigned short seq_num, unsigned long frag_off, unsigned long frag_len);
 
 int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len);
 int dtls1_write_bytes(SSL *s, int type, const void *buf, int len);