| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_media.c,v 1.31 2017/01/25 07:17:19 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center. | | 9 | * NASA Ames Research Center. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -66,27 +66,27 @@ | | | @@ -66,27 +66,27 @@ |
66 | | | 66 | |
67 | /* | | 67 | /* |
68 | * BSD/OS-compatible network interface media selection. | | 68 | * BSD/OS-compatible network interface media selection. |
69 | * | | 69 | * |
70 | * Where it is safe to do so, this code strays slightly from the BSD/OS | | 70 | * Where it is safe to do so, this code strays slightly from the BSD/OS |
71 | * design. Software which uses the API (device drivers, basically) | | 71 | * design. Software which uses the API (device drivers, basically) |
72 | * shouldn't notice any difference. | | 72 | * shouldn't notice any difference. |
73 | * | | 73 | * |
74 | * Many thanks to Matt Thomas for providing the information necessary | | 74 | * Many thanks to Matt Thomas for providing the information necessary |
75 | * to implement this interface. | | 75 | * to implement this interface. |
76 | */ | | 76 | */ |
77 | | | 77 | |
78 | #include <sys/cdefs.h> | | 78 | #include <sys/cdefs.h> |
79 | __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.31 2017/01/25 07:17:19 msaitoh Exp $"); | | 79 | __KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.32 2017/01/25 07:19:24 msaitoh Exp $"); |
80 | | | 80 | |
81 | #include <sys/param.h> | | 81 | #include <sys/param.h> |
82 | #include <sys/systm.h> | | 82 | #include <sys/systm.h> |
83 | #include <sys/errno.h> | | 83 | #include <sys/errno.h> |
84 | #include <sys/ioctl.h> | | 84 | #include <sys/ioctl.h> |
85 | #include <sys/socket.h> | | 85 | #include <sys/socket.h> |
86 | #include <sys/malloc.h> | | 86 | #include <sys/malloc.h> |
87 | | | 87 | |
88 | #include <net/if.h> | | 88 | #include <net/if.h> |
89 | #include <net/if_media.h> | | 89 | #include <net/if_media.h> |
90 | #include <net/netisr.h> | | 90 | #include <net/netisr.h> |
91 | | | 91 | |
92 | /* | | 92 | /* |
| @@ -409,26 +409,28 @@ ifmedia_delete_instance(struct ifmedia * | | | @@ -409,26 +409,28 @@ ifmedia_delete_instance(struct ifmedia * |
409 | } | | 409 | } |
410 | } | | 410 | } |
411 | | | 411 | |
412 | void | | 412 | void |
413 | ifmedia_removeall(struct ifmedia *ifm) | | 413 | ifmedia_removeall(struct ifmedia *ifm) |
414 | { | | 414 | { |
415 | struct ifmedia_entry *ife, *nife; | | 415 | struct ifmedia_entry *ife, *nife; |
416 | | | 416 | |
417 | for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { | | 417 | for (ife = TAILQ_FIRST(&ifm->ifm_list); ife != NULL; ife = nife) { |
418 | nife = TAILQ_NEXT(ife, ifm_list); | | 418 | nife = TAILQ_NEXT(ife, ifm_list); |
419 | TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); | | 419 | TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); |
420 | free(ife, M_IFMEDIA); | | 420 | free(ife, M_IFMEDIA); |
421 | } | | 421 | } |
| | | 422 | ifm->ifm_cur = NULL; |
| | | 423 | ifm->ifm_media = IFM_NONE; |
422 | } | | 424 | } |
423 | | | 425 | |
424 | | | 426 | |
425 | /* | | 427 | /* |
426 | * Compute the interface `baudrate' from the media, for the interface | | 428 | * Compute the interface `baudrate' from the media, for the interface |
427 | * metrics (used by routing daemons). | | 429 | * metrics (used by routing daemons). |
428 | */ | | 430 | */ |
429 | static const struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = | | 431 | static const struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = |
430 | IFM_BAUDRATE_DESCRIPTIONS; | | 432 | IFM_BAUDRATE_DESCRIPTIONS; |
431 | | | 433 | |
432 | uint64_t | | 434 | uint64_t |
433 | ifmedia_baudrate(int mword) | | 435 | ifmedia_baudrate(int mword) |
434 | { | | 436 | { |