Changeset 046fe12b in rtems


Ignore:
Timestamp:
Apr 28, 2009, 11:12:03 AM (11 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, master
Children:
8c44190a
Parents:
d8b74dbe
Message:

2009-04-28 Chris Johns <chrisj@…>

  • libnetworking/nfs/bootp_subr.c: Fixed PR1384. The route set in the initialise pass is not deleted so an exists error is returned. Ignore the error. Print the server address as an IP address not hex digits.
  • libnetworking/rtems/rtems_dhcp.c: Fixed PR1338. Close the socket, handle the returned event flags.
Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rd8b74dbe r046fe12b  
     12009-04-28      Chris Johns <chrisj@rtems.org>
     2
     3        * libnetworking/nfs/bootp_subr.c: Fixed PR1384. The route set in
     4        the initialise pass is not deleted so an exists error is
     5        returned. Ignore the error. Print the server address as an IP
     6        address not hex digits. 
     7
     8        * libnetworking/rtems/rtems_dhcp.c: Fixed
     9        PR1338. Close the socket, handle the returned event flags.
     10       
    1112009-04-28      Chris Johns <chrisj@rtems.org>
    212
  • cpukit/libnetworking/nfs/bootp_subr.c

    rd8b74dbe r046fe12b  
    465465                } /* while secs */
    466466        } /* forever send/receive */
    467 
    468         printf("BOOTP timeout for server 0x%x\n",
    469                (int)ntohl(sin->sin_addr.s_addr));
    470 
     467        {
     468                uint32_t addr = ntohl(sin->sin_addr.s_addr);
     469        printf("BOOTP timeout for server %lu.%lu.%lu.%lu\n",
     470               (addr >> 24) & 0xff, (addr >> 16) & 0xff,
     471               (addr >> 8) & 0xff, addr & 0xff);
     472        }
    471473        error = ETIMEDOUT;
    472474        goto out;
     
    519521  sin->sin_addr.s_addr = INADDR_ANY;
    520522  error = ifioctl(so, SIOCSIFADDR, (caddr_t)ireq, procp);
    521   if (error) {
     523  /*
     524   * Ignore a File already exists (EEXIST) error code. This means a
     525   * route for the address is already present and is returned on
     526   * a second pass to here.
     527   */
     528  if (error && (error != EEXIST)) {
    522529    printf("bootpc_fakeup_interface: set if addr, error=%s\n", strerror(error));
    523530    return error;
     
    550557  }
    551558 
    552  
    553559  /* Add default route to 0.0.0.0 so we can send data */
    554560 
     
    574580                    RTF_UP | RTF_STATIC
    575581                    , NULL);
    576   if (error)
    577     printf("bootpc_fakeup_interface: add default route, error=%d\n", error);
     582  if (error && error != EEXIST)
     583    printf("bootpc_fakeup_interface: add default route, error=%s\n",
     584           strerror(error));
     585 
    578586  return error;
    579587}
  • cpukit/libnetworking/rtems/rtems_dhcp.c

    rd8b74dbe r046fe12b  
    690690  struct proc *procp = NULL;
    691691  int                 disconnected;
     692  rtems_status_code   ev_st;
    692693 
    693694  sdl = (struct sockaddr_dl *) _sdl;
     
    696697  disconnected = 0;
    697698 
    698 
    699   while (TRUE)
     699  while (true)
    700700  {
    701701    /*
     
    703703     */
    704704    timeout = TOD_MILLISECONDS_TO_TICKS (1000);
    705     rtems_event_receive (RTEMS_EVENT_0,
    706                          RTEMS_WAIT | RTEMS_EVENT_ANY,
    707                          timeout, &event_out);
    708 
    709     if(event_out & RTEMS_EVENT_0) break;
     705    ev_st = rtems_event_receive (RTEMS_EVENT_0,
     706                                 RTEMS_WAIT | RTEMS_EVENT_ANY,
     707                                 timeout, &event_out);
     708
     709    /*
     710     * Check if not a poll timeout. So when ANY event received, exit task.
     711     * Actually, only event RTEMS_EVENT_0 sent from rtem_dhcp_failsafe.c
     712     * if "failsafe" dhcp enabled when interface down.  Otherwise, no
     713     * event should occur, just timeout.
     714     */
     715    if(ev_st != RTEMS_TIMEOUT)
     716        break;
    710717
    711718    count++;
     
    715722      rtems_bsdnet_semaphore_obtain ();
    716723     
    717       dhcp_request_req (&call, &dhcp_req, sdl, TRUE);
     724      dhcp_request_req (&call, &dhcp_req, sdl, true);
    718725
    719726      /*
     
    879886
    880887  if ((error = socreate (AF_INET, &so, SOCK_DGRAM, 0, procp)) != 0) {
    881     printf ("dhcpc_init: socreate, error=%d\n", error);
     888    printf ("dhcpc_init: socreate, error: %s\n", strerror(error));
    882889    return -1;
    883890  }
     
    897904  if (!sdl){
    898905    printf ("dhcpc_init: Unable to find HW address\n");
     906    soclose (so);
    899907    return -1;
    900908  }
     
    902910    printf ("dhcpc_init: HW address len is %d, expected value is %d\n",
    903911           sdl->sdl_alen, EALEN);
     912    soclose (so);
    904913    return -1;
    905914  }
     
    915924  error = bootpc_call (&call, &reply, procp);
    916925  if (error) {
    917     printf ("BOOTP call failed -- error %d\n", error);
     926    printf ("BOOTP call failed -- %s\n", strerror(error));
     927    soclose (so);
    918928    return -1;
    919929  }
     
    924934  if (memcmp (&reply.vend[0], dhcp_magic_cookie, sizeof (dhcp_magic_cookie)) != 0) {
    925935    printf ("DHCP server did not send Magic Cookie.\n");
     936    soclose (so);
    926937    return -1;
    927938  }
     
    931942  if (dhcp_message_type != DHCP_OFFER) {
    932943    printf ("DHCP server did not send a DHCP Offer.\n");
     944    soclose (so);
    933945    return -1;
    934946  }
     
    937949   * Send a DHCP REQUEST
    938950   */
    939   dhcp_request_req (&call, &reply, sdl, TRUE);
     951  dhcp_request_req (&call, &reply, sdl, true);
    940952 
    941953  error = bootpc_call (&call, &reply, procp);
    942954  if (error) {
    943     printf ("BOOTP call failed -- error %d\n", error);
     955    printf ("BOOTP call failed -- %s\n", strerror(error));
     956    soclose (so);
    944957    return -1;
    945958  }
     
    950963  if (memcmp (&reply.vend[0], dhcp_magic_cookie, sizeof (dhcp_magic_cookie)) != 0) {
    951964    printf ("DHCP server did not send Magic Cookie.\n");
     965    soclose (so);
    952966    return -1;
    953967  }
     
    957971  if (dhcp_message_type != DHCP_ACK) {
    958972    printf ("DHCP server did not accept the DHCP request\n");
     973    soclose (so);
    959974    return -1;
    960975  }
     
    11071122void rtems_bsdnet_do_dhcp (void)
    11081123{
     1124  bool update = true;
    11091125  rtems_bsdnet_semaphore_obtain ();
    1110   while( dhcp_init (TRUE) < 0 ) {
     1126  while( dhcp_init (update) < 0 ) {
     1127    update = false;
    11111128    rtems_bsdnet_semaphore_release();
    11121129    rtems_task_wake_after(TOD_MILLISECONDS_TO_TICKS(1000));
     
    11211138
    11221139  rtems_bsdnet_semaphore_obtain ();
    1123   return_value = dhcp_init (FALSE);
     1140  return_value = dhcp_init (false);
    11241141  rtems_bsdnet_semaphore_release ();
    11251142
Note: See TracChangeset for help on using the changeset viewer.