Dhcp HostName isn't mandatory.
[reactos.git] / reactos / base / services / dhcp / dhclient.c
index ed7ff2d..39a3de4 100644 (file)
@@ -525,7 +525,7 @@ void setup_adapter( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) {
               &Adapter->NteContext,
               &Adapter->NteInstance );
         if (hkey) {
-            RegSetValueExA(hkey, "DhcpIPAddress", 0, REG_SZ, (LPBYTE)new_lease->address.iabuf, strlen(new_lease->address.iabuf)+1);
+            RegSetValueExA(hkey, "DhcpIPAddress", 0, REG_SZ, (LPBYTE)piaddr(new_lease->address), strlen(piaddr(new_lease->address))+1);
             Buffer[0] = '\0';
             for(i = 0; i < new_lease->options[DHO_SUBNET_MASK].len; i++)
             {
@@ -606,7 +606,7 @@ bind_lease(struct interface_info *ip)
 
     note("bound to %s -- renewal in %ld seconds.",
          piaddr(ip->client->active->address),
-         ip->client->active->renewal - cur_time);
+         (long int)(ip->client->active->renewal - cur_time));
 
     ip->client->state = S_BOUND;
 
@@ -1035,7 +1035,7 @@ send_discover(void *ipp)
 
        note("DHCPDISCOVER on %s to %s port %d interval %ld",
            ip->name, inet_ntoa(sockaddr_broadcast.sin_addr),
-           ntohs(sockaddr_broadcast.sin_port), ip->client->interval);
+           ntohs(sockaddr_broadcast.sin_port), (long int)ip->client->interval);
 
        /* Send out a packet. */
        (void)send_packet(ip, &ip->client->packet, ip->client->packet_length,
@@ -1088,8 +1088,8 @@ state_panic(void *ipp)
                             ip->client->active->renewal) {
                             ip->client->state = S_BOUND;
                             note("bound: renewal in %ld seconds.",
-                                 ip->client->active->renewal -
-                                 cur_time);
+                                 (long int)(ip->client->active->renewal -
+                                 cur_time));
                             add_timeout(
                                 ip->client->active->renewal,
                                 state_bound, ip);
@@ -1563,7 +1563,7 @@ rewrite_client_leases(void)
        if (!leaseFile) {
                leaseFile = fopen(path_dhclient_db, "w");
                if (!leaseFile)
-                       error("can't create %s: %m", path_dhclient_db);
+                       error("can't create %s: %s", path_dhclient_db, strerror(errno));
        } else {
                fflush(leaseFile);
                rewind(leaseFile);
@@ -1600,7 +1600,7 @@ write_client_lease(struct interface_info *ip, struct client_lease *lease,
        if (!leaseFile) {       /* XXX */
                leaseFile = fopen(path_dhclient_db, "w");
                if (!leaseFile)
-                       error("can't create %s: %m", path_dhclient_db);
+                       error("can't create %s: %s", path_dhclient_db, strerror(errno));
        }
 
        fprintf(leaseFile, "lease {\n");
@@ -1655,7 +1655,7 @@ script_init(char *reason, struct string_list *medium)
            sizeof(size_t) + strlen(reason);
 
        if ((buf = buf_open(hdr.len)) == NULL)
-               error("buf_open: %m");
+               error("buf_open: %s", strerror(errno));
 
        errs = 0;
        errs += buf_add(buf, &hdr, sizeof(hdr));
@@ -1667,10 +1667,10 @@ script_init(char *reason, struct string_list *medium)
        errs += buf_add(buf, reason, len);
 
        if (errs)
-               error("buf_add: %m");
+               error("buf_add: %s", strerror(errno));
 
        if (buf_close(privfd, buf) == -1)
-               error("buf_close: %m");
+               error("buf_close: %s", strerror(errno));
 }
 
 void
@@ -1775,7 +1775,7 @@ supersede:
                                case ACTION_APPEND:
                                        len = ip->client->
                                            config->defaults[i].len +
-                                           lease->options[i].len;
+                                           lease->options[i].len + 1;
                                        if (len > sizeof(dbuf)) {
                                                warning("no space to %s %s",
                                                    "append option",
@@ -1848,7 +1848,7 @@ script_write_params(char *prefix, struct client_lease *lease)
        scripttime = time(NULL);
 
        if ((buf = buf_open(hdr.len)) == NULL)
-               error("buf_open: %m");
+               error("buf_open: %s", strerror(errno));
 
        errs = 0;
        errs += buf_add(buf, &hdr, sizeof(hdr));
@@ -1868,10 +1868,10 @@ script_write_params(char *prefix, struct client_lease *lease)
        }
 
        if (errs)
-               error("buf_add: %m");
+               error("buf_add: %s", strerror(errno));
 
        if (buf_close(privfd, buf) == -1)
-               error("buf_close: %m");
+               error("buf_close: %s", strerror(errno));
 }
 
 int
@@ -1961,11 +1961,9 @@ check_option(struct client_lease *l, int option)
        case DHO_HOST_NAME:
        case DHO_DOMAIN_NAME:
        case DHO_NIS_DOMAIN:
-               if (!res_hnok(sbuf)) {
+               if (!res_hnok(sbuf))
                        warning("Bogus Host Name option %d: %s (%s)", option,
                            sbuf, opbuf);
-                       return (0);
-               }
                return (1);
        case DHO_PAD:
        case DHO_TIME_OFFSET: