core: fix const-ness for msg operations

Either an msg parameter is meant for input of output.

A parameter for input (i.e. the message that you want to send) should
not be changed, or at least it should be changed in a deterministic way.

This PR makes `[in]` parameters `const`.