[BACK]Return to if-options.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / external / bsd / dhcpcd / dist / src

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/external/bsd/dhcpcd/dist/src/if-options.c between version 1.1.1.31 and 1.1.1.32

version 1.1.1.31, 2021/10/22 13:21:59 version 1.1.1.32, 2023/04/21 16:52:33
Line 1 
Line 1 
 /* SPDX-License-Identifier: BSD-2-Clause */  /* SPDX-License-Identifier: BSD-2-Clause */
 /*  /*
  * dhcpcd - DHCP client daemon   * dhcpcd - DHCP client daemon
  * Copyright (c) 2006-2021 Roy Marples <roy@marples.name>   * Copyright (c) 2006-2023 Roy Marples <roy@marples.name>
  * All rights reserved   * All rights reserved
   
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
Line 193  add_environ(char ***array, const char *v
Line 193  add_environ(char ***array, const char *v
         l = strlen(match);          l = strlen(match);
   
         while (list && list[i]) {          while (list && list[i]) {
                 if (match && strncmp(list[i], match, l) == 0) {                  /* We know that it must contain '=' due to the above test */
                   size_t listl = (size_t)(strchr(list[i], '=') - list[i]);
   
                   if (l == listl && strncmp(list[i], match, l) == 0) {
                         if (uniq) {                          if (uniq) {
                                 n = strdup(value);                                  n = strdup(value);
                                 if (n == NULL) {                                  if (n == NULL) {
Line 266  parse_str(char *sbuf, size_t slen, const
Line 269  parse_str(char *sbuf, size_t slen, const
                 }                  }
         } else {          } else {
                 l = (size_t)hwaddr_aton(NULL, str);                  l = (size_t)hwaddr_aton(NULL, str);
                 if ((ssize_t) l != -1 && l > 1) {                  if (l > 0) {
                           if ((ssize_t)l == -1) {
                                   errno = ENOBUFS;
                                   return -1;
                           }
                           if (sbuf == NULL)
                                   return (ssize_t)l;
                         if (l > slen) {                          if (l > slen) {
                                 errno = ENOBUFS;                                  errno = ENOBUFS;
                                 return -1;                                  return -1;
Line 1108  parse_option(struct dhcpcd_ctx *ctx, con
Line 1117  parse_option(struct dhcpcd_ctx *ctx, con
                         logerrx("static assignment required");                          logerrx("static assignment required");
                         return -1;                          return -1;
                 }                  }
                 p++;                  p = strskipwhite(++p);
                 if (strncmp(arg, "ip_address=", strlen("ip_address=")) == 0) {                  if (strncmp(arg, "ip_address=", strlen("ip_address=")) == 0) {
                           if (p == NULL) {
                                   ifo->options &= ~DHCPCD_STATIC;
                                   ifo->req_addr.s_addr = INADDR_ANY;
                                   break;
                           }
                         if (parse_addr(&ifo->req_addr,                          if (parse_addr(&ifo->req_addr,
                             ifo->req_mask.s_addr == 0 ? &ifo->req_mask : NULL,                              ifo->req_mask.s_addr == 0 ? &ifo->req_mask : NULL,
                             p) != 0)                              p) != 0)
Line 1120  parse_option(struct dhcpcd_ctx *ctx, con
Line 1134  parse_option(struct dhcpcd_ctx *ctx, con
                 } else if (strncmp(arg, "subnet_mask=",                  } else if (strncmp(arg, "subnet_mask=",
                     strlen("subnet_mask=")) == 0)                      strlen("subnet_mask=")) == 0)
                 {                  {
                           if (p == NULL) {
                                   ifo->req_mask.s_addr = INADDR_ANY;
                                   break;
                           }
                         if (parse_addr(&ifo->req_mask, NULL, p) != 0)                          if (parse_addr(&ifo->req_mask, NULL, p) != 0)
                                 return -1;                                  return -1;
                 } else if (strncmp(arg, "broadcast_address=",                  } else if (strncmp(arg, "broadcast_address=",
                     strlen("broadcast_address=")) == 0)                      strlen("broadcast_address=")) == 0)
                 {                  {
                           if (p == NULL) {
                                   ifo->req_brd.s_addr = INADDR_ANY;
                                   break;
                           }
                         if (parse_addr(&ifo->req_brd, NULL, p) != 0)                          if (parse_addr(&ifo->req_brd, NULL, p) != 0)
                                 return -1;                                  return -1;
                 } else if (strncmp(arg, "routes=", strlen("routes=")) == 0 ||                  } else if (strncmp(arg, "routes=", strlen("routes=")) == 0 ||
Line 1137  parse_option(struct dhcpcd_ctx *ctx, con
Line 1159  parse_option(struct dhcpcd_ctx *ctx, con
                 {                  {
                         struct in_addr addr3;                          struct in_addr addr3;
   
                           if (p == NULL) {
                                   rt_headclear(&ifo->routes, AF_INET);
                                   add_environ(&ifo->config, arg, 1);
                                   break;
                           }
   
                         fp = np = strwhite(p);                          fp = np = strwhite(p);
                         if (np == NULL) {                          if (np == NULL) {
                                 logerrx("all routes need a gateway");                                  logerrx("all routes need a gateway");
Line 1159  parse_option(struct dhcpcd_ctx *ctx, con
Line 1187  parse_option(struct dhcpcd_ctx *ctx, con
                         if (rt_proto_add_ctx(&ifo->routes, rt, ctx))                          if (rt_proto_add_ctx(&ifo->routes, rt, ctx))
                                 add_environ(&ifo->config, arg, 0);                                  add_environ(&ifo->config, arg, 0);
                 } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {                  } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
                           if (p == NULL) {
                                   rt_headclear(&ifo->routes, AF_INET);
                                   add_environ(&ifo->config, arg, 1);
                                   break;
                           }
                         if (parse_addr(&addr, NULL, p) == -1)                          if (parse_addr(&addr, NULL, p) == -1)
                                 return -1;                                  return -1;
                         if ((rt = rt_new0(ctx)) == NULL)                          if ((rt = rt_new0(ctx)) == NULL)
Line 1173  parse_option(struct dhcpcd_ctx *ctx, con
Line 1206  parse_option(struct dhcpcd_ctx *ctx, con
                     strlen("interface_mtu=")) == 0 ||                      strlen("interface_mtu=")) == 0 ||
                     strncmp(arg, "mtu=", strlen("mtu=")) == 0)                      strncmp(arg, "mtu=", strlen("mtu=")) == 0)
                 {                  {
                           if (p == NULL)
                                   break;
                         ifo->mtu = (unsigned int)strtou(p, NULL, 0,                          ifo->mtu = (unsigned int)strtou(p, NULL, 0,
                             MTU_MIN, MTU_MAX, &e);                              MTU_MIN, MTU_MAX, &e);
                         if (e) {                          if (e) {
Line 1180  parse_option(struct dhcpcd_ctx *ctx, con
Line 1215  parse_option(struct dhcpcd_ctx *ctx, con
                                 return -1;                                  return -1;
                         }                          }
                 } else if (strncmp(arg, "ip6_address=", strlen("ip6_address=")) == 0) {                  } else if (strncmp(arg, "ip6_address=", strlen("ip6_address=")) == 0) {
                           if (p == NULL) {
                                   memset(&ifo->req_addr6, 0,
                                       sizeof(ifo->req_addr6));
                                   break;
                           }
   
                         np = strchr(p, '/');                          np = strchr(p, '/');
                         if (np)                          if (np)
                                 *np++ = '\0';                                  *np++ = '\0';
Line 1205  parse_option(struct dhcpcd_ctx *ctx, con
Line 1246  parse_option(struct dhcpcd_ctx *ctx, con
                                 return -1;                                  return -1;
                         }                          }
                 } else                  } else
                         add_environ(&ifo->config, arg, 1);                          add_environ(&ifo->config, arg, p == NULL ? 1 : 0);
                 break;                  break;
   
         case 'W':          case 'W':
                 if (parse_addr(&addr, &addr2, arg) != 0)                  if (parse_addr(&addr, &addr2, arg) != 0)
                         return -1;                          return -1;
Line 2061  err_sla:
Line 2103  err_sla:
                 arg = fp;                  arg = fp;
                 fp = strend(arg);                  fp = strend(arg);
                 if (fp == NULL) {                  if (fp == NULL) {
                         logerrx("authtoken requies an a key");                          logerrx("authtoken requires a realm");
                         goto invalid_token;                          goto invalid_token;
                 }                  }
                 *fp++ = '\0';                  *fp++ = '\0';
Line 2114  err_sla:
Line 2156  err_sla:
                         if (s == -1)                          if (s == -1)
                                 logerr("token_len");                                  logerr("token_len");
                         else                          else
                                 logerrx("authtoken needs a key");                                  logerrx("authtoken requires a key");
                         goto invalid_token;                          goto invalid_token;
                 }                  }
                 token->key_len = (size_t)s;                  token->key_len = (size_t)s;
Line 2229  invalid_token:
Line 2271  invalid_token:
                         ifo->options |= DHCPCD_SLAACPRIVATE;                          ifo->options |= DHCPCD_SLAACPRIVATE;
                 else                  else
                         ifo->options &= ~DHCPCD_SLAACPRIVATE;                          ifo->options &= ~DHCPCD_SLAACPRIVATE;
   #ifdef INET6
                   if (strcmp(arg, "token") == 0) {
                           if (np == NULL) {
                                   logerrx("slaac token: no token specified");
                                   return -1;
                           }
                           arg = np;
                           np = strwhite(np);
                           if (np != NULL) {
                                   *np++ = '\0';
                                   np = strskipwhite(np);
                           }
                           if (inet_pton(AF_INET6, arg, &ifo->token) != 1) {
                                   logerrx("slaac token: invalid token");
                                   return -1;
                           }
                   }
   #endif
                 if (np != NULL &&                  if (np != NULL &&
                     (strcmp(np, "temp") == 0 || strcmp(np, "temporary") == 0))                      (strcmp(np, "temp") == 0 || strcmp(np, "temporary") == 0))
                         ifo->options |= DHCPCD_SLAACTEMP;                          ifo->options |= DHCPCD_SLAACTEMP;

Legend:
Removed from v.1.1.1.31  
changed lines
  Added in v.1.1.1.32

CVSweb <webmaster@jp.NetBSD.org>