I am running NetBSD 6.1.4, and I have an stunnel instance with the following configuration:
[https service] accept = 443 CAfile = /u01/usbtether/CA/certs/rootCA.crt cert = /usr/pkg/etc/stunnel/stunnel.pem pty = yes exec = /usr/sbin/pppd execargs = pppd call phone verify = 2 client = no
Everything works nicely, except for an ever increasing rx error count on the other side. I want to compare the ppp traffic before and after it leaves the stunnel. My strategy thus far is to use socat. I changed the exec lines to point to a shell script like
#!/bin/sh socat -,echo=0,raw SYSTEM:'tee /root/pppd-in.log | socat -,echo=0,raw EXEC:"/usr/sbin/pppd call phone" | tee /root/pppd-out.log'
But I cannot seem to get my ducks in a row. I've managed to loopback everything the other pppd sends, or ignore everything the other pppd sends, but I cannot get the syntax right to actually pass the data between stunnel and pppd while also dumping input and output to a file(although I only care about output).
I've also tried
#!/bin/sh /usr/sbin/pppd call phone | tee /root/serial-out.log
But I just seem to send gibberish back to the calling pppd (I assume the pipe through tee is like not including raw in socat?).
So what is the best way to snoop on the data in a PTY?
For added interest, the data I receive on the other side of the stunnel is occasionally scrambled a little bit. For example, I may receive a ppp frame with an IP packet of length 100, followed by a 0x7e, and 10 additional bytes. Another frame, (which may have arrived several frames before or after the frame with extra bytes) will arrive with an IP packet that is missing 8 bytes. If I were to take that extra chunk and tack it onto the end, I would have, presumably, the correct IP packet plus the FCS. My intention with the PTY snoop is to verify if pppd is sending the data like that (since the missing chunk is always preceded by a 0x7e byte, I think this is likely), or if something weird is happening in transit.