Optimize ipv4/ipv6 formatting

IPv4/IPv6 formatting relied on multiple objects until the final string
was produced. This fixes the way the algorithm operates to make it more
obvious, but also more performant.

Change-Id: Idcfbde227e999dc78363c87952bca7dfb376c5b7
Signed-off-by: Robert Varga <rovarga@cisco.com>
Use 0-shifting operand

Do not use sign-dependent operator. Should not matter, as we follow up
with mask, but this makes the intent obvious.

Change-Id: Ie5c4df5373d19f6abe8b48df5b965ee43bf3e8eb
Signed-off-by: Robert Varga <rovarga@cisco.com>