ping: Fix aliasing violations

Based on patch by Bernhard Rosenkraenzer

Change-Id: Id60dc18cb72c95980f66f7e61d9bc67b012f7488