The protocolentry class allows you to look up entries from /etc/protocols or from elsewhere if you're using the Name Service Switch.