common: Support more flexible vector serialization

Support serialization of vectors containing elements which can have
different sizes. Also allow putting vectors at any position of packet
(not only at the end).