Return GWG IP protocol (version) when no gateway IP - 2.1 version

This is the code from pull request #984, integrated for the 2.1 branch.