Check out SourceForge for some existing sources for Firewalls. And be prepared to learn a lot about sockets and networking.