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.
In this daemon, confusion has already happened.
We applied ifmedia64 corrections in places where IFT_ values are used,
and missed some real ifmedia64 fixes.
Index: ldpctl/ldpctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldpctl/ldpctl.c,v
retrieving revision 1.22
diff -u -p -r1.22 ldpctl.c
--- ldpctl/ldpctl.c 13 Sep 2015 11:13:12 -0000 1.22
+++ ldpctl/ldpctl.c 26 Sep 2015 18:01:29 -0000
@@ -42,10 +42,10 @@
__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 show_discovery_msg(struct imsg *);
-int get_ifms_type(int);
+uint64_t get_ifms_type(uint8_t);
int show_lib_msg(struct imsg *);
int show_nbr_msg(struct imsg *);
void show_fib_head(void);
@@ -247,10 +247,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;
@@ -331,7 +331,7 @@ show_interface_msg(struct imsg *imsg)
printf("%-11s %-10s %-10s %-8s %12s %3u\n",
iface->name, 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), timers,
iface->adj_cnt);
@@ -522,18 +522,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(", ");
@@ -630,13 +630,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: ldpd/interface.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldpd/interface.c,v
retrieving revision 1.25
diff -u -p -r1.25 interface.c
--- ldpd/interface.c 21 Jul 2015 04:43:28 -0000 1.25
+++ ldpd/interface.c 26 Sep 2015 17:56:10 -0000
@@ -71,7 +71,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;
return (iface);
}
@@ -265,7 +265,7 @@ if_to_ctl(struct iface *iface)
ictl.flags = iface->flags;
ictl.type = iface->type;
ictl.linkstate = iface->linkstate;
- ictl.mediatype = iface->media_type;
+ ictl.if_type = iface->if_type;
gettimeofday(&now, NULL);
if (iface->state != IF_STA_DOWN &&
Index: ldpd/kroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldpd/kroute.c,v
retrieving revision 1.46
diff -u -p -r1.46 kroute.c
--- ldpd/kroute.c 21 Jul 2015 04:52:29 -0000 1.46
+++ ldpd/kroute.c 26 Sep 2015 17:56:26 -0000
@@ -799,7 +799,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: ldpd/ldpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/ldpd/ldpd.h,v
retrieving revision 1.55
diff -u -p -r1.55 ldpd.h
--- ldpd/ldpd.h 21 Jul 2015 05:01:46 -0000 1.55
+++ ldpd/ldpd.h 26 Sep 2015 17:56:48 -0000
@@ -230,7 +230,7 @@ struct iface {
u_int16_t hello_interval;
u_int16_t flags;
enum iface_type type;
- u_int8_t media_type;
+ u_int8_t if_type;
u_int8_t linkstate;
};
@@ -375,7 +375,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;
};
@@ -391,7 +391,7 @@ struct ctl_iface {
u_int16_t hello_interval;
enum iface_type type;
u_int8_t linkstate;
- u_int8_t mediatype;
+ u_int8_t if_type;
};
struct ctl_adj {
Index: ldpd/parse.y
===================================================================
RCS file: /cvs/src/usr.sbin/ldpd/parse.y,v
retrieving revision 1.30
diff -u -p -r1.30 parse.y
--- ldpd/parse.y 21 Jul 2015 04:56:44 -0000 1.30
+++ ldpd/parse.y 26 Sep 2015 17:57:27 -0000
@@ -350,7 +350,7 @@ pseudowire : PSEUDOWIRE STRING {
}
free($2);
- if (kif->media_type != IFT_MPLSTUNNEL) {
+ if (kif->if_type != IFT_MPLSTUNNEL) {
yyerror("unsupported interface type on "
"interface %s", kif->ifname);
YYERROR;
@@ -422,7 +422,7 @@ l2vpnopts : PWTYPE pw_type {
YYERROR;
}
- if (kif->media_type != IFT_BRIDGE) {
+ if (kif->if_type != IFT_BRIDGE) {
yyerror("unsupported interface type on "
"interface %s", kif->ifname);
YYERROR;
@@ -452,9 +452,9 @@ l2vpnopts : PWTYPE pw_type {
}
free($2);
- if (kif->media_type == IFT_BRIDGE
- || kif->media_type == IFT_LOOP
- || kif->media_type == IFT_CARP) {
+ if (kif->if_type == IFT_BRIDGE
+ || kif->if_type == IFT_LOOP
+ || kif->if_type == IFT_CARP) {
yyerror("unsupported interface type on "
"interface %s", kif->ifname);
YYERROR;
@@ -487,9 +487,9 @@ interface : INTERFACE STRING {
iface = conf_get_if(kif);
if (iface == NULL)
YYERROR;
- if (iface->media_type == IFT_LOOP ||
- iface->media_type == IFT_CARP ||
- iface->media_type == IFT_MPLSTUNNEL) {
+ if (iface->if_type == IFT_LOOP ||
+ iface->if_type == IFT_CARP ||
+ iface->if_type == IFT_MPLSTUNNEL) {
yyerror("unsupported interface type on "
"interface %s", iface->name);
YYERROR;