+//
+// Helper routine for the TBF filters.
+// Used to send queued data in from the user.
+//
+void send_ipin(sessionidt s, u8 *buf, int len)
+{
+ LOG_HEX(5, "IP in throttled", buf, len);
+
+ if (write(tunfd, buf, len) < 0)
+ {
+ STAT(tun_tx_errors);
+ LOG(0, 0, 0, 0, "Error writing %d bytes to TUN device: %s (tunfd=%d, p=%p)\n",
+ len, strerror(errno), tunfd, buf);
+
+ return;
+ }
+
+ if (session[s].snoop_ip && session[s].snoop_port)
+ {
+ // Snooping this session
+ snoop_send_packet(buf + 4, len - 4, session[s].snoop_ip, session[s].snoop_port);
+ }
+
+ // Increment packet counters
+ session[s].cin += len - 4;
+ session[s].total_cin += len - 4;
+ sess_count[s].cin += len - 4;
+
+ session[s].pin++;
+ eth_tx += len - 4;
+
+ STAT(tun_tx_packets);
+ INC_STAT(tun_tx_bytes, len - 4);
+}
+
+
+// Process CCP messages
+void processccp(tunnelidt t, sessionidt s, u8 *p, u16 l)