In the line 605 to 608 of m_devget
, there is a code segment look like this
if (off) {
cp += off + 2 * sizeof(u_short);
totlen -= 2 * sizeof(u_short);
}
What is the 2 * sizeof(u_short)
for?
In the line 605 to 608 of m_devget
, there is a code segment look like this
if (off) {
cp += off + 2 * sizeof(u_short);
totlen -= 2 * sizeof(u_short);
}
What is the 2 * sizeof(u_short)
for?
The function in question copies data from device memory into an mbuf
structure.
If off
(initialised to the off0
parameter) is non-zero, it means that the packet being processed is trailer-encapsulated, so the code has to skip the type and length fields. Each of those fields are 16-bit wide. The code assumes u_short
is 16-bit wide, as well.