Add some functions for packet encoding.