mirror of
https://github.com/espressif/openthread.git
synced 2026-07-10 06:10:21 +00:00
75ac125771
This commit refactors the code to set frame version, IE present field in frame control field and to append Header IE. - Split UpdateFrameControlField into two methods: CalcIePresent and CalcFrameVersion. Currently UpdateFrameControlField` is not easy-to-read and hard to extend the method to handle more cases. - Move this code from Mac to MeshForwarder. I think it should be MeshForwarder's responsibility (PrepareDataFrame) to prepare the frame (though Mac sometimes prepare data frames itself). Since when preparing the frame, most information comes from the Message which is only in MeshForwarder, we can put this code for preparing frame in MeshForwarder. - Enhance the way to append Header IEs to the frame. Currently in Mac::AppendHeaderIe, it generates a list of HeaderIe first and then call Frame::AppendHeaderIe. There are two problems here: 1. it uses another copy (copy HeaderIe to the frame's buffer). 2. it has to initialize Vendor IE (e.g. TimeSync IE) after Vendor IE header has been copied to the buffer. Currently it directly finds the first Vendor IE in the buffer and initialize it as TimeSync IE, which is not extensible. This commit shifts the responsibility of 'how to append the IE' to Frame, by providing AppendHeaderIeAt method. And MeshForwarder can decide which IEs to append and directly call the method to append IEs to the frame.