Lines 131-148
Link Here
|
131 |
* is not how it is intended. Upcoming rearchitecting the client should |
131 |
* is not how it is intended. Upcoming rearchitecting the client should |
132 |
* address this "one daemon model." |
132 |
* address this "one daemon model." |
133 |
*/ |
133 |
*/ |
134 |
void |
134 |
isc_result_t |
135 |
form_duid(struct data_string *duid, const char *file, int line) |
135 |
form_duid(struct data_string *duid, const char *file, int line) |
136 |
{ |
136 |
{ |
137 |
struct interface_info *ip; |
137 |
struct interface_info *ip; |
138 |
int len; |
138 |
int len; |
|
|
139 |
int fd; |
140 |
int flag; |
139 |
|
141 |
|
140 |
/* For now, just use the first interface on the list. */ |
142 |
/* For now, just use the first interface on the list. */ |
141 |
ip = interfaces; |
143 |
ip = interfaces; |
|
|
144 |
flag = 0; |
142 |
|
145 |
|
143 |
if (ip == NULL) |
146 |
if (ip == NULL) |
144 |
log_fatal("Impossible condition at %s:%d.", MDL); |
147 |
log_fatal("Impossible condition at %s:%d.", MDL); |
145 |
|
148 |
|
|
|
149 |
while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) { |
150 |
fd = open("/dev/urandom", O_RDONLY); |
151 |
if (fd != -1) { |
152 |
if(read(fd, ip->hw_address.hbuf + 1, 6) == 6) { |
153 |
ip->hw_address.hbuf[0] = HTYPE_ETHER; |
154 |
ip->hw_address.hlen = 7; |
155 |
close(fd); |
156 |
flag = 1; |
157 |
break; |
158 |
} |
159 |
close(fd); |
160 |
} |
161 |
if (!ip->hw_address.hlen && ip->v6address_count) { |
162 |
ip->hw_address.hbuf[0] = HTYPE_ETHER; |
163 |
ip->hw_address.hlen = 7; |
164 |
memcpy(ip->hw_address.hbuf + 1, |
165 |
ip->v6addresses[0].s6_addr, 6); |
166 |
for(len = 0 ; len < 10 ; len ++) { |
167 |
fd = len % 6; |
168 |
ip->hw_address.hbuf[fd + 1] ^= |
169 |
ip->v6addresses[0].s6_addr[len + 6]; |
170 |
} |
171 |
flag = 1; |
172 |
break; |
173 |
} |
174 |
/* Try the other interfaces */ |
175 |
log_debug("Cannot form default DUID from interface %s.", ip->name); |
176 |
ip = ip->next; |
177 |
} |
178 |
if (ip == NULL) { |
179 |
return ISC_R_UNEXPECTED; |
180 |
} |
181 |
|
146 |
if ((ip->hw_address.hlen == 0) || |
182 |
if ((ip->hw_address.hlen == 0) || |
147 |
(ip->hw_address.hlen > sizeof(ip->hw_address.hbuf))) |
183 |
(ip->hw_address.hlen > sizeof(ip->hw_address.hbuf))) |
148 |
log_fatal("Impossible hardware address length at %s:%d.", MDL); |
184 |
log_fatal("Impossible hardware address length at %s:%d.", MDL); |
Lines 178-183
Link Here
|
178 |
memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1, |
214 |
memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1, |
179 |
ip->hw_address.hlen - 1); |
215 |
ip->hw_address.hlen - 1); |
180 |
} |
216 |
} |
|
|
217 |
if (flag) |
218 |
memset(ip->hw_address.hbuf, 0, 7); |
219 |
return ISC_R_SUCCESS; |
181 |
} |
220 |
} |
182 |
|
221 |
|
183 |
/* |
222 |
/* |
Lines 4945-4951
Link Here
|
4945 |
*/ |
4984 |
*/ |
4946 |
if ((oc = lookup_option(&dhcpv6_universe, *op, |
4985 |
if ((oc = lookup_option(&dhcpv6_universe, *op, |
4947 |
D6O_CLIENTID)) == NULL) { |
4986 |
D6O_CLIENTID)) == NULL) { |
4948 |
if (!option_cache(&oc, &default_duid, NULL, clientid_option, |
4987 |
if (default_duid.len == 0 || |
|
|
4988 |
!option_cache(&oc, &default_duid, NULL, clientid_option, |
4949 |
MDL)) |
4989 |
MDL)) |
4950 |
log_fatal("Failure assembling a DUID."); |
4990 |
log_fatal("Failure assembling a DUID."); |
4951 |
|
4991 |
|