buf_append_tlv(buf, val, 4, d);
}
-static void buf_hexdump(struct openconnect_info *vpninfo, unsigned char *d, int len)
-{
- char linebuf[80];
- int i;
-
- for (i = 0; i < len; i++) {
- if (i % 16 == 0) {
- if (i)
- vpn_progress(vpninfo, PRG_DEBUG, "%s\n", linebuf);
- sprintf(linebuf, "%04x:", i);
- }
- sprintf(linebuf + strlen(linebuf), " %02x", d[i]);
- }
- vpn_progress(vpninfo, PRG_DEBUG, "%s\n", linebuf);
-}
-
static const char authpkt_head[] = { 0x00, 0x04, 0x00, 0x00, 0x00 };
static const char authpkt_tail[] = { 0xbb, 0x01, 0x00, 0x00, 0x00, 0x00 };
eparse:
vpn_progress(vpninfo, PRG_ERR,
_("Failed to parse KMP message\n"));
- buf_hexdump(vpninfo, bytes, pktlen);
+ dump_buf_hex(vpninfo, PRG_ERR, '<', bytes, pktlen);
return -EINVAL;
}
ret = buf_error(reqbuf);
goto out;
}
- buf_hexdump(vpninfo, (void *)reqbuf->data, reqbuf->pos);
+ dump_buf_hex(vpninfo, PRG_DEBUG, '>', (void *)reqbuf->data, reqbuf->pos);
ret = vpninfo->ssl_write(vpninfo, reqbuf->data, reqbuf->pos);
if (ret != reqbuf->pos) {
if (ret >= 0) {
goto out;
vpn_progress(vpninfo, PRG_TRACE,
_("Read %d bytes of SSL record\n"), ret);
-
+
if (ret != 3 || bytes[0] != 1 || bytes[1] != 0) {
vpn_progress(vpninfo, PRG_ERR,
_("Unexpected response of size %d after hostname packet\n"),
if (len < 0x16 || load_le16(bytes) + 2 != len) {
vpn_progress(vpninfo, PRG_ERR,
_("Invalid packet waiting for KMP 301\n"));
- buf_hexdump(vpninfo, bytes, len);
+ dump_buf_hex(vpninfo, PRG_ERR, '<', bytes, len);
ret = -EINVAL;
goto out;
}
/* Length at the start of the packet is little-endian */
store_le16(reqbuf->data, reqbuf->pos - 2);
- buf_hexdump(vpninfo, (void *)reqbuf->data, reqbuf->pos);
+ vpn_progress(vpninfo, PRG_DEBUG, _("oNCP negotiation request outgoing:\n"));
+ dump_buf_hex(vpninfo, PRG_DEBUG, '>', (void *)reqbuf->data, reqbuf->pos);
ret = vpninfo->ssl_write(vpninfo, reqbuf->data, reqbuf->pos);
if (ret == reqbuf->pos)
ret = 0;
unknown_pkt:
vpn_progress(vpninfo, PRG_ERR,
_("Unknown KMP message %d of size %d:\n"), kmp, kmplen);
- buf_hexdump(vpninfo, vpninfo->cstp_pkt->oncp.kmp,
- vpninfo->cstp_pkt->len);
+ dump_buf_hex(vpninfo, PRG_ERR, '<', vpninfo->cstp_pkt->oncp.kmp,
+ vpninfo->cstp_pkt->len);
if (kmplen + 20 != vpninfo->cstp_pkt->len)
vpn_progress(vpninfo, PRG_DEBUG,
_(".... + %d more bytes unreceived\n"),
unmonitor_write_fd(vpninfo, ssl);
vpn_progress(vpninfo, PRG_TRACE, _("Packet outgoing:\n"));
- buf_hexdump(vpninfo, vpninfo->current_ssl_pkt->oncp.rec,
- vpninfo->current_ssl_pkt->len + 22);
+ dump_buf_hex(vpninfo, PRG_TRACE, '>',
+ vpninfo->current_ssl_pkt->oncp.rec,
+ vpninfo->current_ssl_pkt->len + 22);
ret = ssl_nonblock_write(vpninfo,
vpninfo->current_ssl_pkt->oncp.rec,