dhcp-option.c revision 32008a9636b3781112d349e77ee9e3279104b01c
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2013 Intel Corporation. All rights reserved.
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 <stdint.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include "dhcp-internal.h"
switch (code) {
case DHCP_OPTION_PAD:
case DHCP_OPTION_END:
return -ENOBUFS;
*offset += 1;
break;
default:
return -ENOBUFS;
break;
}
return 0;
}
void *user_data) {
case DHCP_OPTION_PAD:
offset++;
break;
case DHCP_OPTION_END:
return 0;
case DHCP_OPTION_MESSAGE_TYPE:
return -ENOBUFS;
if (len != 1)
return -EINVAL;
if (message_type)
else
offset++;
offset++;
break;
case DHCP_OPTION_OVERLOAD:
return -ENOBUFS;
if (len != 1)
return -EINVAL;
if (overload)
else
offset++;
offset++;
break;
default:
return -ENOBUFS;
return -EINVAL;
if (cb)
break;
}
}
return -EINVAL;
return 0;
}
uint8_t message_type = 0;
int r;
if (!message)
return -EINVAL;
if (len < sizeof(DHCPMessage))
return -EINVAL;
len -= sizeof(DHCPMessage);
if (r < 0)
return r;
if (overload & DHCP_OVERLOAD_FILE) {
if (r < 0)
return r;
}
if (overload & DHCP_OVERLOAD_SNAME) {
if (r < 0)
return r;
}
if (message_type)
return message_type;
return -ENOMSG;
}