openflow
openflow copied to clipboard
Create a uniform function to align the messages
The OpenFlow specification mentions about the message padding, that forces some
of the structures with variable size to be aligned up to 8-byte boundary. Currently the
ofp package does not have any uniform approach to deal with it, instead it contains
copy-pasted snippets, like this one below:
padding := make([]byte, (header.Len+7)/8*8-header.Len)
nn, err := encoding.ReadFrom(r, padding)
Therefore, it would be better to refactor this part and introduce a new function as part of
the encoding package, that will handle this automatically (e.g. ReadFullFrom(r, &values, 8)).