Erik Nordmark wrote:
> [EMAIL PROTECTED] wrote:
>
>> Everytime the networking code wants to know how long the
>> packet is, it is necessary to call msgdsize() - or similar.
>> In the best cast, this requires a simple bit of pointer arithmetic,
>> but otherwise becomes a linked list walk. Costly.
>
>
> I think ipha_length works just fine.
> The only exception is where IP needs to verify that the length of the
> received packet is consistent with ipha_length.
So, to use an example of IP code today, code like this:
len_needed += ipst->ips_ip_icmp_return;
msg_len = msgdsize(mp);
if (msg_len > len_needed) {
(void) adjmsg(mp, len_needed - msg_len);
msg_len = len_needed;
}
should become:
len_needed += ipst->ips_ip_icmp_return;
msg_len = ntohs(ipha->ipha_length);
if (msg_len > len_needed) {
(void) adjmsg(mp, len_needed - msg_len);
msg_len = len_needed;
}
...which I think is safe. There are a few others scattered around but...
...ugh, we need an ip_snmp.c
Darren
_______________________________________________
networking-discuss mailing list
[email protected]