dhcp-packet.c revision fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2
/***
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 <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <net/ethernet.h>
#include "util.h"
#include "list.h"
#include "dhcp-protocol.h"
#include "dhcp-lease-internal.h"
#include "dhcp-internal.h"
#include "sd-dhcp-lease.h"
#include "sd-dhcp-client.h"
#define DHCP_CLIENT_MIN_OPTIONS_SIZE 312
int err;
if (*optlen < 4)
return -ENOBUFS;
*optlen -= 4;
(*opt)[0] = 0x63;
*opt += 4;
&type);
if (err < 0)
return err;
return 0;
}
int i;
sum = 0;
for (i = 0; i < len / 2 ; i++)
if (len & 0x01) {
}
while (sum >> 16)
return ~sum;
}
}
/* IP */
if (len < DHCP_IP_SIZE) {
" smaller than IP header (%u bytes)", len,
return -EINVAL;
}
return -EINVAL;
}
if (hdrlen < 20) {
"smaller than minimum (20 bytes)", hdrlen);
return -EINVAL;
}
"smaller than expected (%zu) by IP header", len,
hdrlen);
return -EINVAL;
}
return -EINVAL;
}
/* UDP */
if (len < DHCP_IP_UDP_SIZE) {
" smaller than IP+UDP header (%u bytes)", len,
return -EINVAL;
}
"smaller than expected (%zu) by UDP header", len,
return -EINVAL;
}
return -EINVAL;
}
}
"is not the DHCP client port (%u)",
return -EINVAL;
}
return 0;
}