Added handlePacket and switch case accourding to the given flags