Changeset 947e2ef in mainline


Ignore:
Timestamp:
2013-09-15T16:28:06Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7af0cc5, b9f7848b
Parents:
b8b1adb1
Message:

Determine MAC address for DHCP automatically.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/dhcp/dhcp.c

    rb8b1adb1 r947e2ef  
    5353
    5454static int transport_fd = -1;
    55 static addr48_t mac_addr;
     55static inet_link_info_t link_info;
    5656static uint8_t msgbuf[MAX_MSG_SIZE];
    5757
     
    132132        hdr->flags = flag_broadcast;
    133133
    134         addr48(mac_addr, hdr->chaddr);
     134        addr48(link_info.mac_addr, hdr->chaddr);
    135135        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    136136
     
    178178        hdr->flags = flag_broadcast;
    179179        hdr->ciaddr = host2uint32_t_be(offer->oaddr.addr);
    180         addr48(mac_addr, hdr->chaddr);
     180        addr48(link_info.mac_addr, hdr->chaddr);
    181181        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    182182
     
    387387                rc = dnsr_set_srvaddr(&offer->dns_server);
    388388                if (rc != EOK) {
    389                         printf("%s: Failed setting nameserver address (%d))\n",
     389                        printf("%s: Error setting nameserver address (%d))\n",
    390390                            NAME, rc);
    391391                        return rc;
     
    413413        rc = inetcfg_init();
    414414        if (rc != EOK) {
    415                 printf("Failed contacting inet configuration service.\n");
     415                printf("Error contacting inet configuration service.\n");
    416416                return 1;
    417417        }
     
    419419        rc = loc_service_get_id(argv[1], &iplink, 0);
    420420        if (rc != EOK) {
    421                 printf("Failed resolving service '%s'.\n", argv[1]);
    422                 return 1;
    423         }
    424 
    425         /* XXX Determine MAC address automatically */
    426         mac_addr[0] = 0xaa;
    427         mac_addr[1] = 0xde;
    428         mac_addr[2] = 0xad;
    429         mac_addr[3] = 0xbe;
    430         mac_addr[4] = 0xef;
    431         mac_addr[5] = 0xfe;
     421                printf("Error resolving service '%s'.\n", argv[1]);
     422                return 1;
     423        }
     424
     425        /* Get link hardware address */
     426        rc = inetcfg_link_get(iplink, &link_info);
     427        if (rc != EOK) {
     428                printf("Error getting properties for link '%s'.\n", argv[1]);
     429                return 1;
     430        }
    432431
    433432        laddr.sin_family = AF_INET;
Note: See TracChangeset for help on using the changeset viewer.