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.
Some ifmedia64 fixes here as well.
Index: ripctl/ripctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ripctl/ripctl.c,v
retrieving revision 1.13
diff -u -p -r1.13 ripctl.c
--- ripctl/ripctl.c 13 Sep 2015 11:13:12 -0000 1.13
+++ ripctl/ripctl.c 26 Sep 2015 18:31:23 -0000
@@ -40,9 +40,9 @@
__dead void usage(void);
const char *fmt_timeframe_core(time_t);
-const char *get_linkstate(uint64_t, int);
+const char *get_linkstate(uint8_t, int);
int show_interface_msg(struct imsg *);
-int get_ifms_type(int);
+uint64_t get_ifms_type(uint8_t);
int show_rib_msg(struct imsg *);
int show_nbr_msg(struct imsg *);
void show_fib_head(void);
@@ -50,7 +50,7 @@ int show_fib_msg(struct imsg *);
void show_interface_head(void);
int show_fib_interface_msg(struct imsg *);
const char *get_media_descr(uint64_t);
-void print_baudrate(u_int64_t);
+void print_baudrate(uint64_t);
struct imsgbuf *ibuf;
@@ -217,10 +217,10 @@ main(int argc, char *argv[])
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);
break;
@@ -301,7 +301,7 @@ show_interface_msg(struct imsg *imsg)
err(1, NULL);
printf("%-11s %-18s %-10s %-10s %-8s\n",
iface->name, netid, if_state_name(iface->state),
- get_linkstate(iface->mediatype, iface->linkstate),
+ get_linkstate(iface->if_type, iface->linkstate),
iface->uptime == 0 ? "00:00:00" :
fmt_timeframe_core(iface->uptime));
free(netid);
@@ -442,18 +442,18 @@ int
show_fib_interface_msg(struct imsg *imsg)
{
struct kif *k;
- int ifms_type;
+ uint64_t ifms_type;
switch (imsg->hdr.type) {
case IMSG_CTL_IFINFO:
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(", ");
@@ -489,13 +489,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);
@@ -503,7 +503,7 @@ get_linkstate(uint64_t media_type, int l
}
void
-print_baudrate(u_int64_t baudrate)
+print_baudrate(uint64_t baudrate)
{
if (baudrate > IF_Gbps(1))
printf("%llu GBit/s", baudrate / IF_Gbps(1));
Index: ripd/interface.c
===================================================================
RCS file: /cvs/src/usr.sbin/ripd/interface.c,v
retrieving revision 1.12
diff -u -p -r1.12 interface.c
--- ripd/interface.c 9 Feb 2015 12:13:42 -0000 1.12
+++ ripd/interface.c 26 Sep 2015 18:27:57 -0000
@@ -425,7 +425,7 @@ if_new(struct kif *kif)
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;
/* get address */
@@ -494,7 +494,7 @@ if_to_ctl(struct iface *iface)
ictl.type = iface->type;
ictl.linkstate = iface->linkstate;
ictl.passive = iface->passive;
- ictl.mediatype = iface->media_type;
+ ictl.if_type = iface->if_type;
gettimeofday(&now, NULL);
Index: ripd/kroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/ripd/kroute.c,v
retrieving revision 1.30
diff -u -p -r1.30 kroute.c
--- ripd/kroute.c 17 Jul 2015 20:38:33 -0000 1.30
+++ ripd/kroute.c 26 Sep 2015 18:28:08 -0000
@@ -665,7 +665,7 @@ if_change(u_short ifindex, int flags, st
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;
if ((reachable = (flags & IFF_UP) &&
@@ -993,7 +993,7 @@ fetchifs(int ifindex)
kif->k.ifindex = ifm.ifm_index;
kif->k.flags = ifm.ifm_flags;
kif->k.link_state = ifm.ifm_data.ifi_link_state;
- kif->k.media_type = ifm.ifm_data.ifi_type;
+ kif->k.if_type = ifm.ifm_data.ifi_type;
kif->k.baudrate = ifm.ifm_data.ifi_baudrate;
kif->k.mtu = ifm.ifm_data.ifi_mtu;
kif->k.nh_reachable = (kif->k.flags & IFF_UP) &&
Index: ripd/ripd.h
===================================================================
RCS file: /cvs/src/usr.sbin/ripd/ripd.h,v
retrieving revision 1.21
diff -u -p -r1.21 ripd.h
--- ripd/ripd.h 2 Nov 2009 20:28:49 -0000 1.21
+++ ripd/ripd.h 26 Sep 2015 18:27:42 -0000
@@ -181,7 +181,7 @@ struct iface {
enum iface_type type;
enum auth_type auth_type;
u_int8_t linktype;
- u_int8_t media_type;
+ u_int8_t if_type;
u_int8_t passive;
u_int8_t linkstate;
u_int8_t auth_keyid;
@@ -259,7 +259,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 */
};
@@ -282,7 +282,7 @@ struct ctl_iface {
u_int16_t metric;
enum iface_type type;
u_int8_t linkstate;
- u_int8_t mediatype;
+ u_int8_t if_type;
u_int8_t passive;
};