Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/udhcp/packet.c

    r3232 r3621  
    3939        return;
    4040
    41     bb_info_msg(
    42         //" op %x"
     41    bb_error_msg(
     42        //"op %x"
    4343        //" htype %x"
    4444        " hlen %x"
     
    7474    );
    7575    *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0';
    76     bb_info_msg(" chaddr %s", buf);
     76    bb_error_msg("chaddr %s", buf);
    7777}
    7878#endif
     
    8686    bytes = safe_read(fd, packet, sizeof(*packet));
    8787    if (bytes < 0) {
    88         log1("Packet read error, ignoring");
     88        log1("packet read error, ignoring");
    8989        return bytes; /* returns -1 */
    9090    }
     
    9393     || packet->cookie != htonl(DHCP_MAGIC)
    9494    ) {
    95         bb_info_msg("Packet with bad magic, ignoring");
     95        bb_error_msg("packet with bad magic, ignoring");
    9696        return -2;
    9797    }
    98     log1("Received a packet");
     98    log1("received %s", "a packet");
    9999    udhcp_dump_packet(packet);
    100100
     
    144144     * In order to work with those buggy servers,
    145145     * we truncate packets after end option byte.
     146     *
     147     * However, RFC 1542 says "The IP Total Length and UDP Length
     148     * must be large enough to contain the minimal BOOTP header of 300 octets".
     149     * Thus, we retain enough padding to not go below 300 BOOTP bytes.
     150     * Some devices have filters which drop DHCP packets shorter than that.
    146151     */
    147152    padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options);
     153    if (padding > DHCP_SIZE - 300)
     154        padding = DHCP_SIZE - 300;
    148155
    149156    packet.ip.protocol = IPPROTO_UDP;
     
    216223    udhcp_dump_packet(dhcp_pkt);
    217224    padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
     225    if (padding > DHCP_SIZE - 300)
     226        padding = DHCP_SIZE - 300;
    218227    result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
    219228    msg = "write";
Note: See TracChangeset for help on using the changeset viewer.