Lines 602-609
Link Here
|
602 |
if (default_duid.buffer != NULL) |
602 |
if (default_duid.buffer != NULL) |
603 |
data_string_forget(&default_duid, MDL); |
603 |
data_string_forget(&default_duid, MDL); |
604 |
|
604 |
|
605 |
form_duid(&default_duid, MDL); |
605 |
if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS) |
606 |
write_duid(&default_duid); |
606 |
write_duid(&default_duid); |
607 |
} |
607 |
} |
608 |
} |
608 |
} |
609 |
|
609 |
|
Lines 2901-2919
Link Here
|
2901 |
* is not how it is intended. Upcoming rearchitecting the client should |
2901 |
* is not how it is intended. Upcoming rearchitecting the client should |
2902 |
* address this "one daemon model." |
2902 |
* address this "one daemon model." |
2903 |
*/ |
2903 |
*/ |
2904 |
void |
2904 |
isc_result_t |
2905 |
form_duid(struct data_string *duid, const char *file, int line) |
2905 |
form_duid(struct data_string *duid, const char *file, int line) |
2906 |
{ |
2906 |
{ |
2907 |
struct interface_info *ip; |
2907 |
struct interface_info *ip; |
2908 |
int len; |
2908 |
int len; |
2909 |
char *str; |
2909 |
char *str; |
|
|
2910 |
int fd; |
2911 |
int flag; |
2910 |
|
2912 |
|
2911 |
/* For now, just use the first interface on the list. */ |
2913 |
/* For now, just use the first interface on the list. */ |
2912 |
ip = interfaces; |
2914 |
ip = interfaces; |
|
|
2915 |
flag = 0; |
2913 |
|
2916 |
|
2914 |
if (ip == NULL) |
2917 |
if (ip == NULL) |
2915 |
log_fatal("Impossible condition at %s:%d.", MDL); |
2918 |
log_fatal("Impossible condition at %s:%d.", MDL); |
2916 |
|
2919 |
|
|
|
2920 |
while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) { |
2921 |
fd = open("/dev/urandom", O_RDONLY); |
2922 |
if (fd != -1) { |
2923 |
if(read(fd, ip->hw_address.hbuf + 1, 6) == 6) { |
2924 |
ip->hw_address.hbuf[0] = HTYPE_ETHER; |
2925 |
ip->hw_address.hlen = 7; |
2926 |
close(fd); |
2927 |
flag = 1; |
2928 |
break; |
2929 |
} |
2930 |
close(fd); |
2931 |
} |
2932 |
if (!ip->hw_address.hlen && ip->v6address_count) { |
2933 |
ip->hw_address.hbuf[0] = HTYPE_ETHER; |
2934 |
ip->hw_address.hlen = 7; |
2935 |
memcpy(ip->hw_address.hbuf + 1, |
2936 |
ip->v6addresses[0].s6_addr, 6); |
2937 |
for(len = 0 ; len < 10 ; len ++) { |
2938 |
fd = len % 6; |
2939 |
ip->hw_address.hbuf[fd + 1] ^= |
2940 |
ip->v6addresses[0].s6_addr[len + 6]; |
2941 |
} |
2942 |
flag = 1; |
2943 |
break; |
2944 |
} |
2945 |
/* Try the other interfaces */ |
2946 |
log_debug("Cannot form default DUID from interface %s.", ip->name); |
2947 |
ip = ip->next; |
2948 |
} |
2949 |
if (ip == NULL) { |
2950 |
return ISC_R_UNEXPECTED; |
2951 |
} |
2952 |
|
2917 |
if ((ip->hw_address.hlen == 0) || |
2953 |
if ((ip->hw_address.hlen == 0) || |
2918 |
(ip->hw_address.hlen > sizeof(ip->hw_address.hbuf))) |
2954 |
(ip->hw_address.hlen > sizeof(ip->hw_address.hbuf))) |
2919 |
log_fatal("Impossible hardware address length at %s:%d.", MDL); |
2955 |
log_fatal("Impossible hardware address length at %s:%d.", MDL); |
Lines 2950-2955
Link Here
|
2950 |
ip->hw_address.hlen - 1); |
2986 |
ip->hw_address.hlen - 1); |
2951 |
} |
2987 |
} |
2952 |
|
2988 |
|
|
|
2989 |
if (flag) |
2990 |
memset(ip->hw_address.hbuf, 0, 7); |
2991 |
|
2953 |
str = quotify_buf(duid->data, duid->len, MDL); |
2992 |
str = quotify_buf(duid->data, duid->len, MDL); |
2954 |
if (str == NULL) |
2993 |
if (str == NULL) |
2955 |
log_info("Created duid."); |
2994 |
log_info("Created duid."); |
Lines 2957-2962
Link Here
|
2957 |
log_info("Created duid %s.", str); |
2996 |
log_info("Created duid %s.", str); |
2958 |
dfree(str, MDL); |
2997 |
dfree(str, MDL); |
2959 |
} |
2998 |
} |
|
|
2999 |
|
3000 |
return ISC_R_SUCCESS; |
2960 |
} |
3001 |
} |
2961 |
|
3002 |
|
2962 |
/* Write the default DUID to the lease store. */ |
3003 |
/* Write the default DUID to the lease store. */ |