/***
This file is part of systemd.
Copyright (C) 2013 Intel Corporation. All rights reserved.
Copyright (C) 2014 Tom Gundersen
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <net/ethernet.h>
#include <string.h>
#include "dhcp-internal.h"
#include "dhcp-protocol.h"
int r;
if (r < 0)
return r;
return 0;
}
/* See RFC1071 */
/* wrap around in one's complement */
sum++;
buf_64 ++;
}
/* If the buffer is not aligned to 64-bit, we need
to zero-pad the last few bytes and add them in */
/* wrap around */
sum++;
}
while (sum >> 16)
return ~sum;
}
}
/* IP */
log_debug("ignoring packet: not IPv4");
return -EINVAL;
}
log_debug("ignoring packet: IPv4 IHL (%u words) invalid",
return -EINVAL;
}
if (hdrlen < 20) {
log_debug("ignoring packet: IPv4 IHL (%zu bytes) "
"smaller than minimum (20 bytes)", hdrlen);
return -EINVAL;
}
log_debug("ignoring packet: packet (%zu bytes) "
"smaller than expected (%zu) by IP header", len,
hdrlen);
return -EINVAL;
}
/* UDP */
log_debug("ignoring packet: not UDP");
return -EINVAL;
}
log_debug("ignoring packet: packet (%zu bytes) "
"smaller than expected (%zu) by UDP header", len,
return -EINVAL;
}
log_debug("ignoring packet: to port %u, which "
"is not the DHCP client port (%u)",
return -EINVAL;
}
/* checksums - computing these is relatively expensive, so only do it
if all the other checks have passed
*/
log_debug("ignoring packet: invalid IP checksum");
return -EINVAL;
}
log_debug("ignoring packet: invalid UDP checksum");
return -EINVAL;
}
}
return 0;
}