dhcp-packet.c revision 0c79c68d93d721d37ba088fb50dbf07bb0d447e5
/***
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;
&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 */
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;
}
/* UDP */
return -EINVAL;
}
"smaller than expected (%zu) by UDP header", len,
return -EINVAL;
}
"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
*/
return -EINVAL;
}
return -EINVAL;
}
}
return 0;
}