~ubuntu-branches/ubuntu/vivid/dnsmasq/vivid-updates

« back to all changes in this revision

Viewing changes to src/rfc3315.c

  • Committer: Package Import Robot
  • Author(s): Simon Kelley
  • Date: 2014-04-23 15:14:42 UTC
  • mfrom: (0.5.8) (12.2.17 sid)
  • Revision ID: package-import@ubuntu.com-20140423151442-22uqxwgu9wi56gd7
Tags: 2.70-1
New upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley
 
1
/* dnsmasq is Copyright (c) 2000-2014 Simon Kelley
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
24
24
  int clid_len, iaid, ia_type, interface, hostname_auth, lease_allocate;
25
25
  char *client_hostname, *hostname, *domain, *send_domain;
26
26
  struct dhcp_context *context;
27
 
  struct in6_addr *link_address, *fallback;
 
27
  struct in6_addr *link_address, *fallback, *ll_addr, *ula_addr;
28
28
  unsigned int xid, fqdn_flags;
29
29
  char *iface_name;
30
30
  void *packet_options, *end;
73
73
 
74
74
 
75
75
unsigned short dhcp6_reply(struct dhcp_context *context, int interface, char *iface_name,
76
 
                           struct in6_addr *fallback, size_t sz, struct in6_addr *client_addr, time_t now)
 
76
                           struct in6_addr *fallback,  struct in6_addr *ll_addr, struct in6_addr *ula_addr,
 
77
                           size_t sz, struct in6_addr *client_addr, time_t now)
77
78
{
78
79
  struct dhcp_vendor *vendor;
79
80
  int msg_type;
93
94
  state.interface = interface;
94
95
  state.iface_name = iface_name;
95
96
  state.fallback = fallback;
 
97
  state.ll_addr = ll_addr;
 
98
  state.ula_addr = ula_addr;
96
99
  state.mac_len = 0;
97
100
  state.tags = NULL;
98
101
  state.link_address = NULL;
1269
1272
            continue;
1270
1273
        }
1271
1274
      
1272
 
      if (opt_cfg->opt == OPTION6_DNS_SERVER)
1273
 
        {
1274
 
          done_dns = 1;
1275
 
          if (opt_cfg->len == 0)
1276
 
            continue;
1277
 
        }
1278
 
 
1279
1275
      if (opt_cfg->opt == OPTION6_REFRESH_TIME)
1280
1276
        done_refresh = 1;
1281
1277
      
1282
 
      o = new_opt6(opt_cfg->opt);
1283
1278
      if (opt_cfg->flags & DHOPT_ADDR6)
1284
1279
        {
1285
 
          int j;
1286
 
          struct in6_addr *a = (struct in6_addr *)opt_cfg->val;
1287
 
          for (j = 0; j < opt_cfg->len; j+=IN6ADDRSZ, a++)
1288
 
            {
1289
 
              /* zero means "self" (but not in vendorclass options.) */
1290
 
              if (IN6_IS_ADDR_UNSPECIFIED(a))
1291
 
                {
1292
 
                  if (!add_local_addrs(state->context))
1293
 
                    put_opt6(state->fallback, IN6ADDRSZ);
 
1280
          int len, j;
 
1281
          struct in6_addr *a;
 
1282
          
 
1283
          if (opt_cfg->opt == OPTION6_DNS_SERVER)
 
1284
            done_dns = 1;
 
1285
          
 
1286
          for (a = (struct in6_addr *)opt_cfg->val, len = opt_cfg->len, j = 0; 
 
1287
               j < opt_cfg->len; j += IN6ADDRSZ, a++)
 
1288
            if ((IN6_IS_ADDR_ULA_ZERO(a) && IN6_IS_ADDR_UNSPECIFIED(state->ula_addr)) ||
 
1289
                (IN6_IS_ADDR_LINK_LOCAL_ZERO(a) && IN6_IS_ADDR_UNSPECIFIED(state->ll_addr)))
 
1290
              len -= IN6ADDRSZ;
 
1291
          
 
1292
          if (len != 0)
 
1293
            {
 
1294
              
 
1295
              o = new_opt6(opt_cfg->opt);
 
1296
                  
 
1297
              for (a = (struct in6_addr *)opt_cfg->val, j = 0; j < opt_cfg->len; j+=IN6ADDRSZ, a++)
 
1298
                {
 
1299
                  if (IN6_IS_ADDR_UNSPECIFIED(a))
 
1300
                    {
 
1301
                      if (!add_local_addrs(state->context))
 
1302
                        put_opt6(state->fallback, IN6ADDRSZ);
 
1303
                    }
 
1304
                  else if (IN6_IS_ADDR_ULA_ZERO(a))
 
1305
                    {
 
1306
                      if (!IN6_IS_ADDR_UNSPECIFIED(state->ula_addr))
 
1307
                        put_opt6(state->ula_addr, IN6ADDRSZ);
 
1308
                    }
 
1309
                  else if (IN6_IS_ADDR_LINK_LOCAL_ZERO(a))
 
1310
                    {
 
1311
                      if (!IN6_IS_ADDR_UNSPECIFIED(state->ll_addr))
 
1312
                        put_opt6(state->ll_addr, IN6ADDRSZ);
 
1313
                    }
 
1314
                  else
 
1315
                    put_opt6(a, IN6ADDRSZ);
1294
1316
                }
1295
 
              else
1296
 
                put_opt6(a, IN6ADDRSZ);
1297
 
            }
1298
 
        }
1299
 
      else if (opt_cfg->val)
1300
 
        put_opt6(opt_cfg->val, opt_cfg->len);
1301
 
      end_opt6(o);
 
1317
 
 
1318
              end_opt6(o);
 
1319
            }
 
1320
        }
 
1321
      else
 
1322
        {
 
1323
          o = new_opt6(opt_cfg->opt);
 
1324
          if (opt_cfg->val)
 
1325
            put_opt6(opt_cfg->val, opt_cfg->len);
 
1326
          end_opt6(o);
 
1327
        }
1302
1328
    }
1303
1329
  
1304
1330
  if (daemon->port == NAMESERVER_PORT && !done_dns)