Engineer from Télécom Paris
Ph.D Thesis from UPMC

Network & Security IT - MI
Check news about my company

ISPEED/OSPEED PATCH FOR SOCAT

Patch for SOCAT correcting a bug when changing default speed of a serial asynchronous line, that occurs on some systems like FreeBSD.


SYNOPSYS

With SOCAT (at least up to version 1.7.3.1) on systems where b0 to b4000000 options are not available, like FreeBSD, setting the speed of a TERMIOS terminal is done using the ispeed and ospeed options.

But when using simultaneously ispeed and ospeed parameters with SOCAT, the speed values are set within two distinct ioctl requests, so changing the speed of terminals or devices that need matching input and output returns an Invalid argument error (the TIOCSETA/TIOCSETAW/TIOCSETAF ioctl returns -1 and sets errno to EINVAL).

This is especially the case On FreeBSD, where many tty device drivers need matching input and output speeds:
  • - those that depend on ucom(4): uark(4), ubsa(4), ubser(4), uftdi(4), umcs(4), uplcom(4), uslcom(4), uvscom(4)
  • - some others, even not depending on ucom(4): uart(4), sio(4), digi(4), rp(4)
But some don't: tty(4)

With those drivers, the input and output speeds must match and be set inside a single ioctl request (TIOCSETA, TIOCSETAW or TIOCSETAF). The only exception to this rule is when the input baud rate is zero because, according to POSIX, in that case, the input baud rate is set equal to the output baud rate.

For instance, this call to SOCAT on FreeBSD 10.1 terminates immediately with an EINVAL error:
# socat -d /dev/cuaU2,ispeed=57600,ospeed=57600,echo=0,raw TCP-LISTEN:9000,reuseaddr
2015/03/09 00:43:33 socat[20723] E tcsetattr(3, TCSADRAIN, 0x7fffffffe148): Invalid argument

The status of the bug report on FreeBSD: Bug 198441


INSTALLING ON FreeBSD FROM THE PORTS TREE

- change directory to the SOCAT port directory:
# cd /usr/ports/net/socat
- download the patch: patch.diff
# fetch http://fenyo.net/newweb/socat/patch/patch.diff
- add the patch file to the port:
# mv patch.diff files/patch-xioopts.c
- compile and install the port:
# make
# make install

INSTALLING ON FreeBSD FROM THE PATCHED PORT

- download the SOCAT patched port: socat-port-patched.tar.gz
# fetch http://fenyo.net/newweb/socat/socat-port-patched.tar.gz
- compile and install the port:
# tar zxf socat-port-patched.tar.gz
# cd socat
# make
# make install

Note: you can also download the compiled patched port (compiled for amd64 on 10.1-RELEASE).

INSTALLING ON FreeBSD FROM THE PATCHED PACKAGE

- download the SOCAT patched package: socat-1.7.3.0_1-patched.txz
# fetch http://fenyo.net/newweb/socat/socat-port-patched.tar.gz
- install the package:
# pkg install socat-1.7.3.0_1-patched.txz

INSTALLING FROM THE SOURCES

- download the sources: socat-1.7.3.0.tar.gz
# fetch http://fenyo.net/newweb/socat/socat-1.7.3.0.tar.gz
# tar zxf socat-1.7.3.0.tar.gz

- download the patch: patch.diff
# fetch http://fenyo.net/newweb/socat/patch/patch.diff
- patch the sources:
# cd socat-1.7.3.0
# patch < ../patch.diff
- compile and install SOCAT:
# autoconf
# ./configure
# make
# make install

INSTALLING FROM THE PATCHED SOURCE TREE

- download the patched source tree: socat-1.7.3.0-patched.tar.gz
# fetch http://fenyo.net/newweb/socat/socat-1.7.3.0-patched.tar.gz
# tar zxf socat-1.7.3.0-patched.tar.gz
- compile and install SOCAT:
# cd socat-1.7.3.0-patched
# autoconf
# ./configure
# make
# make install

Top Articles:

ImageElectronic design: driving a 60A relay with a micro-controller
Use this device to drive a 60 Ampere relay in order to power on/off dozens of computers at once.

Image"new_station" patch for hostapd
Improve 802.1X authentication on wired IEEE 802 media, with this patch for hostapd.

Imageusbdrive.exe
Copy, manipulate and erase raw data on your usb flash drive. Essential to really get privacy with your files.

ImageHidden VNC server
This patch for WinVNC 4 allows you to install a hidden VNC server : no more tray icon.

ImageRaccorder son réseau d'entreprise à l'Internet
A free book about networks. First published by Eyrolles in 1997, and under terms of Creative Commons in 2006.
© A. Fenyo - F. Le Guern - S. Tardieu

IP phone to analog phone interface circuit
At work, people usually do not get an analog phone line anymore since numeric or IP phones appeared. See how to connect your old analog device (modem, wireless DECT phone, Minitel) only using your IP phone to get the network access: read this.

Very low cost 20MHz signal generator for ham radio HF power amplifiers testing
Learn how to make a 20MHz HF signal generator using a few simple discrete analog components. Moreover, see how a 33 years old Tektronix oscilloscope gives better results than a numeric one bought recently. The whole story is here.

Split tunneling with Cisco
Enabling split tunneling with Cisco IPsec VPN Linux client software is always possible: read this.

Modelling IEEE Spanning Tree protocols using an UML Class Diagram
To really understand the dependencies between the many Spanning Tree protocols, I wrote an UML class diagram describing their relationships here.

Motorized camera controlled by the telephone
This project demonstrates how to drive a camera from the telephone line, any details here.

External Links:

ImageMy Former Web Site
Since 04/26/01, I maintain a web site named www.fenyo.net. Since I made many updates recently, click here to access the original content, where old informations are kept. The photo is also from 2001 :-)

ImageAgnes' Web Site
Agnes, my wife, used to maintain a web server but she doesn't anymore. Thus, this pointer is disabled. However, you may contact her on LinkedIn.

ImageCanardou's Web Site
Canardou has always been for me a friend that really matters, helping me in every situation. According to informations currently available, Canardou could be affected by the H5N1 virus. So, for a few weeks, Public Health Bird Regulations have made me forbid Canardou to walk away from our appartement. Feel free to take news about him from his personal home page.

Private Links:

ImageMail for nuts
Authorized users at domain fenyo.net can read/send mails by means of this cute Squirrel (a friend of Canardou ?).