this = vpninfo->deflate_pkt;
len = this->len;
} else {
+ uint8_t dontsend;
+
this = dequeue_packet(&vpninfo->outgoing_queue);
if (!this)
break;
+ /* Pulse can only accept ESP of the same protocol as the one you
+ * connected to it with. The other has to go over IF-T/TLS. */
+ if (vpninfo->dtls_addr->sa_family == AF_INET6)
+ dontsend = 0x40;
+ else
+ dontsend = 0x60;
+
+ if ( (this->data[0] & 0xf0) == dontsend) {
+ store_be32(&this->pulse.vendor, 0xa4c);
+ store_be32(&this->pulse.type, 4);
+ store_be32(&this->pulse.len, this->len + 16);
+ queue_packet(&vpninfo->oncp_control_queue, this);
+ work_done = 1;
+ continue;
+ }
len = construct_esp_packet(vpninfo, this, 0);
if (len < 0) {
/* Should we disable ESP? */
vpninfo->stats.tx_bytes += out_pkt->len;
work_done = 1;
- if (queue_packet(&vpninfo->outgoing_queue, out_pkt) ==
- vpninfo->max_qlen) {
+ if (queue_packet(&vpninfo->outgoing_queue, out_pkt) +
+ vpninfo->oncp_control_queue.count >= vpninfo->max_qlen) {
out_pkt = NULL;
unmonitor_read_fd(vpninfo, tun);
break;
out_pkt = NULL;
}
vpninfo->tun_pkt = out_pkt;
- } else if (vpninfo->outgoing_queue.count < vpninfo->max_qlen) {
+ } else if (vpninfo->outgoing_queue.count + vpninfo->oncp_control_queue.count < vpninfo->max_qlen) {
monitor_read_fd(vpninfo, tun);
}
for (seq=1; seq <= (vpninfo->dtls_state==DTLS_CONNECTED ? 1 : 2); seq++) {
pkt->len = 1;
pkt->data[0] = 0;
- pktlen = construct_esp_packet(vpninfo, pkt, IPPROTO_IPIP);
+ pktlen = construct_esp_packet(vpninfo, pkt,
+ vpninfo->dtls_addr->sa_family == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IPIP);
if (pktlen >= 0)
send(vpninfo->dtls_fd, (void *)&pkt->esp, pktlen, 0);
}