~ubuntu-branches/debian/sid/isc-dhcp/sid

« back to all changes in this revision

Viewing changes to server/dhcp.c

  • Committer: Package Import Robot
  • Author(s): Andrew Pollock
  • Date: 2012-06-09 14:01:05 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120609140105-lqcz2t0rsefwzamt
Tags: 4.2.4-1
* New upstream release
* debian/control: reformatted Uploaders so that dch doesn't think I'm making
  NMUs
* debian/rules: do a clean between the LDAP-enabled build and the
  non-LDAP-enabled one, so that no LDAP-related artefacts are accidently
  incorporated into the non-LDAP build
* debian/dhclient-script.*: conditionalise the chown/chmod of the new
  resolv.conf on the existence of the old one (closes: #595400)
* debian/dhclient-script.linux: comply with RFC 3442 and ignore
  the routers option if the rfc3442-classless-static-routes option is present
  (closes: #592735)
* debian/dhclient-script.kfreebsd: fix subnet mask handling (closes: #677985)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   DHCP Protocol engine. */
4
4
 
5
5
/*
6
 
 * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
 
6
 * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
7
7
 * Copyright (c) 1995-2003 by Internet Software Consortium
8
8
 *
9
9
 * Permission to use, copy, modify, and distribute this software for any
419
419
#if defined (FAILOVER_PROTOCOL)
420
420
        dhcp_failover_state_t *peer;
421
421
#endif
422
 
        int have_server_identifier = 0;
423
422
        int have_requested_addr = 0;
424
423
 
425
424
        oc = lookup_option (&dhcp_universe, packet -> options,
473
472
                 * safe.
474
473
                 */
475
474
                sprintf (smbuf, " (%s)", piaddr (sip));
476
 
                have_server_identifier = 1;
477
475
        } else
478
476
                smbuf [0] = 0;
479
477
 
969
967
        struct sockaddr_in to;
970
968
        struct in_addr from;
971
969
        isc_boolean_t zeroed_ciaddr;
 
970
        struct interface_info *interface;
 
971
        int result;
972
972
 
973
973
        /* The client should set ciaddr to its IP address, but apparently
974
974
           it's common for clients not to do this, so we'll use their IP
1169
1169
                                   packet -> options, options,
1170
1170
                                   &global_scope, oc, MDL)) {
1171
1171
                struct universe *u = (struct universe *)0;
1172
 
                
 
1172
 
1173
1173
                if (!universe_hash_lookup (&u, universe_hash,
1174
1174
                                           (const char *)d1.data, d1.len,
1175
1175
                                           MDL)) {
1314
1314
                                            packet->interface->name);
1315
1315
 
1316
1316
        errno = 0;
1317
 
        send_packet ((fallback_interface
1318
 
                      ? fallback_interface : packet -> interface),
1319
 
                     &outgoing, &raw, outgoing.packet_length,
1320
 
                     from, &to, (struct hardware *)0);
 
1317
        interface = (fallback_interface ? fallback_interface
 
1318
                     : packet -> interface);
 
1319
        result = send_packet(interface, &outgoing, &raw,
 
1320
                             outgoing.packet_length, from, &to, NULL);
 
1321
        if (result < 0) {
 
1322
                log_error ("%s:%d: Failed to send %d byte long packet over %s "
 
1323
                           "interface.", MDL, outgoing.packet_length,
 
1324
                           interface->name);
 
1325
        }
 
1326
 
 
1327
 
1321
1328
        if (subnet)
1322
1329
                subnet_dereference (&subnet, MDL);
1323
1330
}
1464
1471
                        result = send_packet(fallback_interface, packet, &raw,
1465
1472
                                             outgoing.packet_length, from, &to,
1466
1473
                                             NULL);
 
1474
                        if (result < 0) {
 
1475
                                log_error ("%s:%d: Failed to send %d byte long "
 
1476
                                           "packet over %s interface.", MDL,
 
1477
                                           outgoing.packet_length,
 
1478
                                           fallback_interface->name);
 
1479
                        }
 
1480
 
1467
1481
                        return;
1468
1482
                }
1469
1483
        } else {
1474
1488
        errno = 0;
1475
1489
        result = send_packet(packet->interface, packet, &raw,
1476
1490
                             outgoing.packet_length, from, &to, NULL);
 
1491
        if (result < 0) {
 
1492
                log_error ("%s:%d: Failed to send %d byte long packet over %s "
 
1493
                           "interface.", MDL, outgoing.packet_length,
 
1494
                           packet->interface->name);
 
1495
        }
 
1496
 
1477
1497
}
1478
1498
 
1479
1499
void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
3164
3184
                        to.sin_port = remote_port; /* For debugging. */
3165
3185
 
3166
3186
                if (fallback_interface) {
3167
 
                        result = send_packet (fallback_interface,
3168
 
                                              (struct packet *)0,
3169
 
                                              &raw, packet_length,
3170
 
                                              raw.siaddr, &to,
3171
 
                                              (struct hardware *)0);
 
3187
                        result = send_packet(fallback_interface, NULL, &raw,
 
3188
                                             packet_length, raw.siaddr, &to,
 
3189
                                             NULL);
 
3190
                        if (result < 0) {
 
3191
                                log_error ("%s:%d: Failed to send %d byte long "
 
3192
                                           "packet over %s interface.", MDL,
 
3193
                                           packet_length,
 
3194
                                           fallback_interface->name);
 
3195
                        }
 
3196
 
3172
3197
 
3173
3198
                        free_lease_state (state, MDL);
3174
3199
                        lease -> state = (struct lease_state *)0;
3197
3222
                to.sin_port = remote_port;
3198
3223
 
3199
3224
                if (fallback_interface) {
3200
 
                        result = send_packet (fallback_interface,
3201
 
                                              (struct packet *)0,
3202
 
                                              &raw, packet_length,
3203
 
                                              raw.siaddr, &to,
3204
 
                                              (struct hardware *)0);
 
3225
                        result = send_packet(fallback_interface, NULL, &raw,
 
3226
                                             packet_length, raw.siaddr, &to,
 
3227
                                             NULL);
 
3228
                        if (result < 0) {
 
3229
                                log_error("%s:%d: Failed to send %d byte long"
 
3230
                                          " packet over %s interface.", MDL,
 
3231
                                           packet_length,
 
3232
                                           fallback_interface->name);
 
3233
                        }
 
3234
 
3205
3235
                        free_lease_state (state, MDL);
3206
3236
                        lease -> state = (struct lease_state *)0;
3207
3237
                        return;
3226
3256
 
3227
3257
        memcpy (&from, state -> from.iabuf, sizeof from);
3228
3258
 
3229
 
        result = send_packet (state -> ip,
3230
 
                              (struct packet *)0, &raw, packet_length,
3231
 
                              from, &to,
3232
 
                              unicastp ? &hto : (struct hardware *)0);
 
3259
        result = send_packet(state->ip, NULL, &raw, packet_length,
 
3260
                              from, &to, unicastp ? &hto : NULL);
 
3261
        if (result < 0) {
 
3262
            log_error ("%s:%d: Failed to send %d byte long "
 
3263
                       "packet over %s interface.", MDL,
 
3264
                       packet_length, state->ip->name);
 
3265
        }
 
3266
 
3233
3267
 
3234
3268
        /* Free all of the entries in the option_state structure
3235
3269
           now that we're done with them. */