Adding whatsapp protocol internals. Translated from libpurple implementation.