dhcp6-option.c revision c6affce8740bb0cee42eebf6d1d44dd518035e88
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 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 <errno.h>
#include <string.h>
#include "sparse-endian.h"
#include "util.h"
#include "dhcp6-internal.h"
#include "dhcp6-protocol.h"
#define DHCP6_OPTION_HDR_LEN 4
#define DHCP6_OPTION_IA_NA_LEN 12
#define DHCP6_OPTION_IA_TA_LEN 4
#define DHCP6_OPTION_IAADDR_LEN 24
return -ENOBUFS;
*buf += DHCP6_OPTION_HDR_LEN;
return 0;
}
int r;
if (r < 0)
return r;
return 0;
}
int r;
case DHCP6_OPTION_IA_NA:
break;
case DHCP6_OPTION_IA_TA:
break;
default:
return -EINVAL;
}
return -ENOBUFS;
*buf += DHCP6_OPTION_HDR_LEN;
if (r < 0)
return r;
}
if (r < 0)
return r;
return 0;
}
if (*buflen < 4)
return -ENOMSG;
return -ENOMSG;
*buf += 4;
*buflen -= 4;
return 0;
}
int r;
if (r < 0)
return r;
return -ENOBUFS;
return 0;
}
int r;
switch (iatype) {
case DHCP6_OPTION_IA_NA:
r = -ENOBUFS;
goto error;
}
r = -EINVAL;
goto error;
}
break;
case DHCP6_OPTION_IA_TA:
r = -ENOBUFS;
goto error;
}
ia->lifetime_t1 = 0;
ia->lifetime_t2 = 0;
break;
default:
r = -ENOMSG;
goto error;
}
*buflen -= iaaddr_offset;
*buf += iaaddr_offset;
switch (opt) {
case DHCP6_OPTION_IAADDR:
if (!addr) {
r = -ENOMEM;
goto error;
}
} else {
}
break;
case DHCP6_OPTION_STATUS_CODE:
break;
if (status) {
status);
r = -EINVAL;
goto error;
}
break;
default:
break;
}
}
if (r == -ENOMSG)
r = 0;
}
if (*buflen)
r = -ENOMSG;
*buflen = 0;
return r;
}