Changeset 0d65339 in rtems


Ignore:
Timestamp:
May 22, 2012, 9:20:07 AM (7 years ago)
Author:
Sebastien Bourdeauducq <sebastien@…>
Branches:
4.10
Children:
89dd2ec4
Parents:
991e1b85
git-author:
Sebastien Bourdeauducq <sebastien@…> (05/22/12 09:20:07)
git-committer:
Gedare Bloom <gedare@…> (01/11/18 17:08:24)
Message:

network/dhcp: PR1841: Fix DNS processing in DHCP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/rtems/rtems_dhcp.c

    r991e1b85 r0d65339  
    206206                                                         DHCP_HOST,
    207207                                                         DHCP_DOMAIN_NAME };
     208#define NUM_NAMESERVERS \
     209  (sizeof rtems_bsdnet_config.name_server / sizeof rtems_bsdnet_config.name_server[0])
     210static struct in_addr rtems_dhcpd_nameserver[NUM_NAMESERVERS];
     211static int rtems_dhcpd_nameserver_count = 0;
     212
     213/*
     214 * Clean any DNS entries add by a DHCP request.
     215 */
     216static void
     217clean_dns_entries (void)
     218{
     219  int e;
     220  for (e = 0; e < rtems_dhcpd_nameserver_count; ++e)
     221  {
     222    int n;
     223    for (n = 0; n < rtems_bsdnet_nameserver_count; ++ n)
     224    {
     225      if (memcmp (&rtems_dhcpd_nameserver[e], &rtems_bsdnet_nameserver[n], 4) == 0)
     226      {
     227        if (n < (NUM_NAMESERVERS - 1))
     228          memmove (&rtems_bsdnet_nameserver[n],
     229                   &rtems_bsdnet_nameserver[n + 1],
     230                   (NUM_NAMESERVERS - n - 1) * 4);
     231        --rtems_bsdnet_nameserver_count;
     232      }
     233    }
     234  }
     235  rtems_dhcpd_nameserver_count = 0;
     236}
    208237
    209238/*
     
    364393          int dlen = 0;
    365394          while ((dlen < len) &&
    366                  (rtems_bsdnet_nameserver_count <
    367                   sizeof rtems_bsdnet_config.name_server /
    368                   sizeof rtems_bsdnet_config.name_server[0]))
     395                 (rtems_dhcpd_nameserver_count < NUM_NAMESERVERS) &&
     396                 (rtems_bsdnet_nameserver_count < NUM_NAMESERVERS))
    369397          {
     398            memcpy (&rtems_dhcpd_nameserver
     399                    [rtems_dhcpd_nameserver_count], p + dlen, 4);
     400            rtems_dhcpd_nameserver_count++;
    370401            memcpy (&rtems_bsdnet_nameserver
    371402                    [rtems_bsdnet_nameserver_count], p + dlen, 4);
     
    746777      }
    747778
     779      /*
     780       * We have an ack. Clear the DNS entries that have been assigned by a previous
     781       * DHCP request.
     782       */
     783      clean_dns_entries ();
     784
     785      /*
     786       * Process this requests options.
     787       */
    748788      process_options (&dhcp_req.vend[4], sizeof (dhcp_req.vend) - 4);
    749789
     
    861901  struct proc          *procp = NULL;
    862902
     903  clean_dns_entries();
     904 
    863905  /*
    864906   * If we are to update the files create the root
Note: See TracChangeset for help on using the changeset viewer.