As done for bgpd recently, rename media_type to if_type.
Rationale: if_type values come from the IFT_ namespace in if_types.h,
not from the IFM_ namespace in if_media.h. This change prevents
confusion between uint8_t interface types and uint64_t media types.
This touches OSPF for IPv4 and for IPv6.
Includes same ifmedia64 fixes as for ldpd.
Index: ospf6ctl/ospf6ctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6ctl/ospf6ctl.c,v
retrieving revision 1.39
diff -u -p -r1.39 ospf6ctl.c
--- ospf6ctl/ospf6ctl.c 13 Sep 2015 11:13:12 -0000 1.39
+++ ospf6ctl/ospf6ctl.c 26 Sep 2015 18:19:38 -0000
@@ -41,7 +41,7 @@
__dead void usage(void);
int show_summary_msg(struct imsg *);
-int get_ifms_type(int);
+uint64_t get_ifms_type(uint8_t);
int show_interface_msg(struct imsg *);
int show_interface_detail_msg(struct imsg *);
const char *print_link(int);
@@ -68,7 +68,7 @@ int show_rib_detail_msg(struct imsg *)
void show_fib_head(void);
int show_fib_msg(struct imsg *);
const char * get_media_descr(uint64_t);
-const char * get_linkstate(uint64_t, int);
+const char * get_linkstate(uint8_t, int);
void print_baudrate(u_int64_t);
struct imsgbuf *ibuf;
@@ -347,10 +347,10 @@ show_summary_msg(struct imsg *imsg)
return (0);
}
-int
-get_ifms_type(int mediatype)
+uint64_t
+get_ifms_type(uint8_t if_type)
{
- switch (mediatype) {
+ switch (if_type) {
case IFT_ETHER:
return (IFM_ETHER);
case IFT_FDDI:
@@ -379,7 +379,7 @@ show_interface_msg(struct imsg *imsg)
printf("%-11s %-29s %-6s %-10s %-10s %s\n",
iface->name, netid, if_state_name(iface->state),
fmt_timeframe_core(iface->hello_timer),
- get_linkstate(iface->mediatype, iface->linkstate),
+ get_linkstate(iface->if_type, iface->linkstate),
fmt_timeframe_core(iface->uptime));
free(netid);
break;
@@ -407,8 +407,8 @@ show_interface_detail_msg(struct imsg *i
printf(" Internet address %s Area %s\n",
log_in6addr(&iface->addr), inet_ntoa(iface->area));
printf(" Link type %s, state %s",
- get_media_descr(get_ifms_type(iface->mediatype)),
- get_linkstate(iface->mediatype, iface->linkstate));
+ get_media_descr(get_ifms_type(iface->if_type)),
+ get_linkstate(iface->if_type, iface->linkstate));
if (iface->linkstate != LINK_STATE_DOWN &&
iface->baudrate > 0) {
printf(", ");
@@ -1323,13 +1323,13 @@ get_media_descr(uint64_t media_type)
}
const char *
-get_linkstate(uint64_t media_type, int link_state)
+get_linkstate(uint8_t if_type, int link_state)
{
const struct if_status_description *p;
static char buf[8];
for (p = if_status_descriptions; p->ifs_string != NULL; p++) {
- if (LINK_STATE_DESC_MATCH(p, media_type, link_state))
+ if (LINK_STATE_DESC_MATCH(p, if_type, link_state))
return (p->ifs_string);
}
snprintf(buf, sizeof(buf), "[#%d]", link_state);
Index: ospf6d/interface.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
retrieving revision 1.21
diff -u -p -r1.21 interface.c
--- ospf6d/interface.c 1 Nov 2013 17:18:29 -0000 1.21
+++ ospf6d/interface.c 26 Sep 2015 18:16:52 -0000
@@ -239,7 +239,7 @@ if_update(struct iface *iface, int mtu,
{
iface->mtu = mtu;
iface->flags = flags;
- iface->media_type = type;
+ iface->if_type = type;
iface->linkstate = state;
iface->baudrate = rate;
@@ -376,7 +376,7 @@ if_act_start(struct iface *iface)
return (0);
}
- if (iface->media_type == IFT_CARP &&
+ if (iface->if_type == IFT_CARP &&
!(iface->cflags & F_IFACE_PASSIVE)) {
/* force passive mode on carp interfaces */
log_warnx("if_act_start: forcing interface %s to passive",
@@ -678,7 +678,7 @@ if_to_ctl(struct iface *iface)
ictl.rxmt_interval = iface->rxmt_interval;
ictl.type = iface->type;
ictl.linkstate = iface->linkstate;
- ictl.mediatype = iface->media_type;
+ ictl.if_type = iface->if_type;
ictl.priority = iface->priority;
ictl.passive = (iface->cflags & F_IFACE_PASSIVE) == F_IFACE_PASSIVE;
Index: ospf6d/ospf6d.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.c,v
retrieving revision 1.27
diff -u -p -r1.27 ospf6d.c
--- ospf6d/ospf6d.c 10 Feb 2015 05:39:10 -0000 1.27
+++ ospf6d/ospf6d.c 26 Sep 2015 18:17:08 -0000
@@ -778,7 +778,7 @@ merge_interfaces(struct area *a, struct
i->priority = xi->priority;
i->flags = xi->flags; /* needed? */
i->type = xi->type; /* needed? */
- i->media_type = xi->media_type; /* needed? */
+ i->if_type = xi->if_type; /* needed? */
i->linkstate = xi->linkstate; /* needed? */
#if 0 /* XXX needs some kind of love */
Index: ospf6d/ospf6d.h
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.h,v
retrieving revision 1.28
diff -u -p -r1.28 ospf6d.h
--- ospf6d/ospf6d.h 25 Mar 2013 14:29:35 -0000 1.28
+++ ospf6d/ospf6d.h 26 Sep 2015 18:16:07 -0000
@@ -316,7 +316,7 @@ struct iface {
u_int16_t dead_interval;
u_int16_t metric;
enum iface_type type;
- u_int8_t media_type;
+ u_int8_t if_type;
u_int8_t linkstate;
u_int8_t priority;
u_int8_t cflags;
@@ -435,7 +435,7 @@ struct ctl_iface {
u_int16_t rxmt_interval;
enum iface_type type;
u_int8_t linkstate;
- u_int8_t mediatype;
+ u_int8_t if_type;
u_int8_t priority;
u_int8_t passive;
};
Index: ospf6d/ospfe.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.c,v
retrieving revision 1.45
diff -u -p -r1.45 ospfe.c
--- ospf6d/ospfe.c 10 Feb 2015 05:39:10 -0000 1.45
+++ ospf6d/ospfe.c 26 Sep 2015 18:17:31 -0000
@@ -288,7 +288,7 @@ ospfe_dispatch_main(int fd, short event,
if (iface == NULL)
fatalx("interface lost in ospfe");
- if_update(iface, ifp->mtu, ifp->flags, ifp->media_type,
+ if_update(iface, ifp->mtu, ifp->flags, ifp->if_type,
ifp->linkstate, ifp->baudrate);
if ((iface->flags & IFF_UP) &&
Index: ospf6d/rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospf6d/rde.c,v
retrieving revision 1.63
diff -u -p -r1.63 rde.c
--- ospf6d/rde.c 16 Jan 2015 06:40:19 -0000 1.63
+++ ospf6d/rde.c 26 Sep 2015 18:17:20 -0000
@@ -720,7 +720,7 @@ rde_dispatch_parent(int fd, short event,
wasvalid = (iface->flags & IFF_UP) &&
LINK_STATE_IS_UP(iface->linkstate);
- if_update(iface, ifp->mtu, ifp->flags, ifp->media_type,
+ if_update(iface, ifp->mtu, ifp->flags, ifp->if_type,
ifp->linkstate, ifp->baudrate);
/* Resend LSAs if interface state changes. */
Index: ospfctl/ospfctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospfctl/ospfctl.c,v
retrieving revision 1.59
diff -u -p -r1.59 ospfctl.c
--- ospfctl/ospfctl.c 13 Sep 2015 11:13:12 -0000 1.59
+++ ospfctl/ospfctl.c 26 Sep 2015 18:15:23 -0000
@@ -40,7 +40,7 @@
__dead void usage(void);
int show_summary_msg(struct imsg *);
-int get_ifms_type(int);
+uint64_t get_ifms_type(uint8_t);
int show_interface_msg(struct imsg *);
int show_interface_detail_msg(struct imsg *);
const char *print_link(int);
@@ -66,7 +66,7 @@ void show_fib_head(void);
int show_fib_msg(struct imsg *);
void show_interface_head(void);
const char * get_media_descr(uint64_t);
-const char * get_linkstate(uint64_t, int);
+const char * get_linkstate(uint8_t, int);
void print_baudrate(u_int64_t);
int show_fib_interface_msg(struct imsg *);
@@ -367,10 +367,10 @@ show_summary_msg(struct imsg *imsg)
return (0);
}
-int
-get_ifms_type(int mediatype)
+uint64_t
+get_ifms_type(uint8_t if_type)
{
- switch (mediatype) {
+ switch (if_type) {
case IFT_ETHER:
return (IFM_ETHER);
case IFT_FDDI:
@@ -401,7 +401,7 @@ show_interface_msg(struct imsg *imsg)
iface->name, netid, if_state_name(iface->state),
iface->hello_timer.tv_sec < 0 ? "-" :
fmt_timeframe_core(iface->hello_timer.tv_sec),
- get_linkstate(iface->mediatype, iface->linkstate),
+ get_linkstate(iface->if_type, iface->linkstate),
fmt_timeframe_core(iface->uptime),
iface->nbr_cnt, iface->adj_cnt);
free(netid);
@@ -432,7 +432,7 @@ show_interface_detail_msg(struct imsg *i
mask2prefixlen(iface->mask.s_addr));
printf("Area %s\n", inet_ntoa(iface->area));
printf(" Linkstate %s\n",
- get_linkstate(iface->mediatype, iface->linkstate));
+ get_linkstate(iface->if_type, iface->linkstate));
printf(" Router ID %s, network type %s, cost: %d\n",
inet_ntoa(iface->rtr_id),
if_type_name(iface->type), iface->metric);
@@ -1289,13 +1289,13 @@ get_media_descr(uint64_t media_type)
}
const char *
-get_linkstate(uint64_t media_type, int link_state)
+get_linkstate(uint8_t if_type, int link_state)
{
const struct if_status_description *p;
static char buf[8];
for (p = if_status_descriptions; p->ifs_string != NULL; p++) {
- if (LINK_STATE_DESC_MATCH(p, media_type, link_state))
+ if (LINK_STATE_DESC_MATCH(p, if_type, link_state))
return (p->ifs_string);
}
snprintf(buf, sizeof(buf), "[#%d]", link_state);
@@ -1326,11 +1326,11 @@ show_fib_interface_msg(struct imsg *imsg
k = imsg->data;
printf("%-15s", k->ifname);
printf("%-15s", k->flags & IFF_UP ? "UP" : "");
- ifms_type = get_ifms_type(k->media_type);
+ ifms_type = get_ifms_type(k->if_type);
if (ifms_type)
printf("%s, ", get_media_descr(ifms_type));
- printf("%s", get_linkstate(k->media_type, k->link_state));
+ printf("%s", get_linkstate(k->if_type, k->link_state));
if (k->link_state != LINK_STATE_DOWN && k->baudrate > 0) {
printf(", ");
Index: ospfd/interface.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospfd/interface.c,v
retrieving revision 1.78
diff -u -p -r1.78 interface.c
--- ospfd/interface.c 20 Jul 2015 23:45:39 -0000 1.78
+++ ospfd/interface.c 26 Sep 2015 18:11:21 -0000
@@ -198,7 +198,7 @@ if_new(struct kif *kif, struct kif_addr
iface->ifindex = kif->ifindex;
iface->flags = kif->flags;
iface->linkstate = kif->link_state;
- iface->media_type = kif->media_type;
+ iface->if_type = kif->if_type;
iface->baudrate = kif->baudrate;
/* set address, mask and p2p addr */
@@ -340,11 +340,11 @@ if_act_start(struct iface *iface)
if (!(iface->flags & IFF_UP) ||
(!LINK_STATE_IS_UP(iface->linkstate) &&
- !(iface->media_type == IFT_CARP &&
+ !(iface->if_type == IFT_CARP &&
iface->linkstate == LINK_STATE_DOWN)))
return (0);
- if (iface->media_type == IFT_CARP && iface->passive == 0) {
+ if (iface->if_type == IFT_CARP && iface->passive == 0) {
/* force passive mode on carp interfaces */
log_warnx("if_act_start: forcing interface %s to passive",
iface->name);
@@ -639,7 +639,7 @@ if_to_ctl(struct iface *iface)
ictl.rxmt_interval = iface->rxmt_interval;
ictl.type = iface->type;
ictl.linkstate = iface->linkstate;
- ictl.mediatype = iface->media_type;
+ ictl.if_type = iface->if_type;
ictl.priority = iface->priority;
ictl.passive = iface->passive;
ictl.auth_type = iface->auth_type;
Index: ospfd/kroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospfd/kroute.c,v
retrieving revision 1.102
diff -u -p -r1.102 kroute.c
--- ospfd/kroute.c 20 Jul 2015 23:45:39 -0000 1.102
+++ ospfd/kroute.c 26 Sep 2015 18:11:43 -0000
@@ -883,7 +883,7 @@ kif_update(u_short ifindex, int flags, s
kif->k.flags = flags;
kif->k.link_state = ifd->ifi_link_state;
- kif->k.media_type = ifd->ifi_type;
+ kif->k.if_type = ifd->ifi_type;
kif->k.baudrate = ifd->ifi_baudrate;
kif->k.mtu = ifd->ifi_mtu;
Index: ospfd/ospfd.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospfd/ospfd.c,v
retrieving revision 1.85
diff -u -p -r1.85 ospfd.c
--- ospfd/ospfd.c 20 Jul 2015 23:45:39 -0000 1.85
+++ ospfd/ospfd.c 26 Sep 2015 18:12:30 -0000
@@ -862,7 +862,7 @@ merge_interfaces(struct area *a, struct
i->self->priority = i->priority;
i->flags = xi->flags; /* needed? */
i->type = xi->type; /* needed? */
- i->media_type = xi->media_type; /* needed? */
+ i->if_type = xi->if_type; /* needed? */
i->linkstate = xi->linkstate; /* needed? */
i->auth_type = xi->auth_type;
Index: ospfd/ospfd.h
===================================================================
RCS file: /cvs/src/usr.sbin/ospfd/ospfd.h,v
retrieving revision 1.91
diff -u -p -r1.91 ospfd.h
--- ospfd/ospfd.h 17 Jan 2013 10:07:56 -0000 1.91
+++ ospfd/ospfd.h 26 Sep 2015 18:11:30 -0000
@@ -345,7 +345,7 @@ struct iface {
u_int16_t metric;
enum iface_type type;
enum auth_type auth_type;
- u_int8_t media_type;
+ u_int8_t if_type;
u_int8_t auth_keyid;
u_int8_t linkstate;
u_int8_t priority;
@@ -416,7 +416,7 @@ struct kif {
int flags;
int mtu;
u_short ifindex;
- u_int8_t media_type;
+ u_int8_t if_type;
u_int8_t link_state;
u_int8_t nh_reachable; /* for nexthop verification */
};
@@ -461,7 +461,7 @@ struct ctl_iface {
u_int16_t rxmt_interval;
enum iface_type type;
u_int8_t linkstate;
- u_int8_t mediatype;
+ u_int8_t if_type;
u_int8_t priority;
u_int8_t passive;
enum auth_type auth_type;
Index: ospfd/ospfe.c
===================================================================
RCS file: /cvs/src/usr.sbin/ospfd/ospfe.c,v
retrieving revision 1.90
diff -u -p -r1.90 ospfe.c
--- ospfd/ospfe.c 10 Feb 2015 05:24:48 -0000 1.90
+++ ospfd/ospfe.c 26 Sep 2015 18:11:56 -0000
@@ -879,7 +879,7 @@ orig_rtr_lsa(struct area *area)
*/
if (!(iface->flags & IFF_UP) ||
(!LINK_STATE_IS_UP(iface->linkstate) &&
- !(iface->media_type == IFT_CARP &&
+ !(iface->if_type == IFT_CARP &&
iface->linkstate == LINK_STATE_DOWN)))
continue;
log_debug("orig_rtr_lsa: stub net, "
@@ -895,7 +895,7 @@ orig_rtr_lsa(struct area *area)
* backup carp interfaces are anounced with high metric
* for faster failover.
*/
- if (iface->media_type == IFT_CARP &&
+ if (iface->if_type == IFT_CARP &&
iface->linkstate == LINK_STATE_DOWN)
rtr_link.metric = MAX_METRIC;
else