/***
This file is part of systemd.
Copyright (C) 2014-2015 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 "sd-dhcp6-client.h"
#include "alloc-util.h"
#include "dhcp6-internal.h"
#include "dhcp6-protocol.h"
#include "dns-domain.h"
#include "sparse-endian.h"
#include "strv.h"
#include "unaligned.h"
#include "util.h"
typedef struct DHCP6Option {
return -ENOBUFS;
*buf += sizeof(DHCP6Option);
*buflen -= sizeof(DHCP6Option);
return 0;
}
int r;
if (r < 0)
return r;
if (optval)
return 0;
}
int r;
case SD_DHCP6_OPTION_IA_NA:
break;
case SD_DHCP6_OPTION_IA_TA:
break;
default:
return -EINVAL;
}
return -ENOBUFS;
*buf += sizeof(DHCP6Option);
*buflen -= sizeof(DHCP6Option);
if (r < 0)
return r;
}
if (r < 0)
return r;
return 0;
}
if (*buflen < sizeof(DHCP6Option))
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 SD_DHCP6_OPTION_IA_NA:
r = -ENOBUFS;
goto error;
}
r = -EINVAL;
goto error;
}
break;
case SD_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 SD_DHCP6_OPTION_IAADDR:
if (!addr) {
r = -ENOMEM;
goto error;
}
} else {
}
break;
break;
if (status) {
status);
r = -EINVAL;
goto error;
}
break;
default:
break;
}
}
if (r == -ENOMSG)
r = 0;
}
if (*buflen)
r = -ENOMSG;
*buflen = 0;
return r;
}
return -EINVAL;
return -ENOMEM;
return count;
}
int r;
bool first = true;
for (;;) {
uint8_t c;
if (c == 0)
/* End of name */
break;
else if (c <= 63) {
const char *label;
/* Literal label */
pos += c;
return -EMSGSIZE;
r = -ENOMEM;
goto fail;
}
if (first)
first = false;
else
ret[n++] = '.';
if (r < 0)
goto fail;
n += r;
continue;
} else {
r = -EBADMSG;
goto fail;
}
}
r = -ENOMEM;
goto fail;
}
ret[n] = 0;
if (r < 0)
goto fail;
idx++;
}
return idx;
fail:
return r;
}