Coding Divert Sockets/Can I Use Them?
Though it might not be the question you really wanted to ask, it is definitely worthy of note before continuing.
Not all kernels are built with divert sockets and a compatible packet filter, and they are required to get divert sockets working. In case either or both of them are missing, you will need to recompile your kernel with IPDIVERT and IPFW enabled.
Note: If you have a preference for a different packet filter--other than the IPFW--it is possible as long as the filter supports divert/tee rules. Be sure to check out your packet filter's documentation on whatever rule you'd like to link to your divert socket(s) and how to do them. (If you would like to add to this book how to link a packet filter rule with a divert socket that isn't the IPFW, your contributions are greatly welcome.)
||This page or section is an undeveloped draft or outline.
You can help to develop the work, or you can ask for assistance in the project room.