libnet: refactor initialization code