Branch: Tag:

2015-03-31

2015-03-31 16:18:01 by Martin Nilsson <nilsson@opera.com>

Changed packet parsing to use Stdio.Buffer objects. The Packet factory is still weird and needs some more thought.

449:      State current_read_state;   State current_write_state; - string(8bit) left_over; + Stdio.Buffer read_buffer = Stdio.Buffer();   Packet packet;      //! Number of application data bytes sent by us.
511:   //! more data is needed to get a complete packet.   protected Packet recv_packet(string(8bit) data)   { -  string(8bit)|Packet res; +  int(0..1)|Packet res;    -  +  read_buffer->add(data); +     // SSL3_DEBUG_MSG("SSL.Connection->recv_packet(%O)\n", data); -  if (left_over || !packet) -  { +  if (!packet)    packet = Packet(version, 2048); -  res = packet->recv( (left_over || "") + data); -  } -  else -  res = packet->recv(data); +     -  if (stringp(res)) +  res = packet->recv(read_buffer); +  +  if(objectp(res)) +  return [object(Packet)]res; +  +  if (res)    { /* Finished a packet */ -  left_over = [string]res; +     if (current_read_state) {    SSL3_DEBUG_MSG("SSL.Connection->recv_packet(): version=0x%x\n",    version);
534:    return 0;    }    } -  else /* Partial packet read, or error */ -  left_over = 0; +     -  return [object]res; +  return 0;   }      //! Queues a packet for write. Handshake and and change cipher
930:    { /* Reply alert */    SSL3_DEBUG_MSG("SSL.Connection: Bad received packet\n");    if (alert_callback) -  alert_callback(packet, current_read_state->seq_num, left_over); +  alert_callback(packet, current_read_state->seq_num, +  (string)read_buffer);    if (this && packet)    send_packet(packet);    if ((!packet) || (!this) || (packet->level == ALERT_fatal))