diff options
| -rw-r--r-- | networking/interface.c | 160 | ||||
| -rw-r--r-- | util-linux/mkfs_minix.c | 2 |
2 files changed, 86 insertions, 76 deletions
diff --git a/networking/interface.c b/networking/interface.c index 7861b9fd9..b09148b27 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
| @@ -91,7 +91,7 @@ struct in6_ifreq { | |||
| 91 | /* Display an Internet socket address. */ | 91 | /* Display an Internet socket address. */ |
| 92 | static const char* FAST_FUNC INET_sprint(struct sockaddr *sap, int numeric) | 92 | static const char* FAST_FUNC INET_sprint(struct sockaddr *sap, int numeric) |
| 93 | { | 93 | { |
| 94 | static char *buff; | 94 | static char *buff; /* defaults to NULL */ |
| 95 | 95 | ||
| 96 | free(buff); | 96 | free(buff); |
| 97 | if (sap->sa_family == 0xFFFF || sap->sa_family == 0) | 97 | if (sap->sa_family == 0xFFFF || sap->sa_family == 0) |
| @@ -916,21 +916,91 @@ static void print_bytes_scaled(unsigned long long ull, const char *end) | |||
| 916 | printf("X bytes:%llu (%llu.%u %sB)%s", ull, int_part, frac_part, ext, end); | 916 | printf("X bytes:%llu (%llu.%u %sB)%s", ull, int_part, frac_part, ext, end); |
| 917 | } | 917 | } |
| 918 | 918 | ||
| 919 | static void ife_print(struct interface *ptr) | ||
| 920 | { | ||
| 921 | const struct aftype *ap; | ||
| 922 | const struct hwtype *hw; | ||
| 923 | int hf; | ||
| 924 | int can_compress = 0; | ||
| 925 | 919 | ||
| 926 | #ifdef HAVE_AFINET6 | 920 | #ifdef HAVE_AFINET6 |
| 921 | #define IPV6_ADDR_ANY 0x0000U | ||
| 922 | |||
| 923 | #define IPV6_ADDR_UNICAST 0x0001U | ||
| 924 | #define IPV6_ADDR_MULTICAST 0x0002U | ||
| 925 | #define IPV6_ADDR_ANYCAST 0x0004U | ||
| 926 | |||
| 927 | #define IPV6_ADDR_LOOPBACK 0x0010U | ||
| 928 | #define IPV6_ADDR_LINKLOCAL 0x0020U | ||
| 929 | #define IPV6_ADDR_SITELOCAL 0x0040U | ||
| 930 | |||
| 931 | #define IPV6_ADDR_COMPATv4 0x0080U | ||
| 932 | |||
| 933 | #define IPV6_ADDR_SCOPE_MASK 0x00f0U | ||
| 934 | |||
| 935 | #define IPV6_ADDR_MAPPED 0x1000U | ||
| 936 | #define IPV6_ADDR_RESERVED 0x2000U /* reserved address space */ | ||
| 937 | |||
| 938 | |||
| 939 | static void ife_print6(struct interface *ptr) | ||
| 940 | { | ||
| 941 | |||
| 927 | FILE *f; | 942 | FILE *f; |
| 928 | char addr6[40], devname[20]; | 943 | char addr6[40], devname[20]; |
| 929 | struct sockaddr_in6 sap; | 944 | struct sockaddr_in6 sap; |
| 930 | int plen, scope, dad_status, if_idx; | 945 | int plen, scope, dad_status, if_idx; |
| 931 | char addr6p[8][5]; | 946 | char addr6p[8][5]; |
| 947 | |||
| 948 | f = fopen_for_read(_PATH_PROCNET_IFINET6); | ||
| 949 | if (f == NULL) | ||
| 950 | return; | ||
| 951 | |||
| 952 | while (fscanf | ||
| 953 | (f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n", | ||
| 954 | addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4], | ||
| 955 | addr6p[5], addr6p[6], addr6p[7], &if_idx, &plen, &scope, | ||
| 956 | &dad_status, devname) != EOF | ||
| 957 | ) { | ||
| 958 | if (!strcmp(devname, ptr->name)) { | ||
| 959 | sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", | ||
| 960 | addr6p[0], addr6p[1], addr6p[2], addr6p[3], | ||
| 961 | addr6p[4], addr6p[5], addr6p[6], addr6p[7]); | ||
| 962 | inet_pton(AF_INET6, addr6, | ||
| 963 | (struct sockaddr *) &sap.sin6_addr); | ||
| 964 | sap.sin6_family = AF_INET6; | ||
| 965 | printf(" inet6 addr: %s/%d", | ||
| 966 | INET6_sprint((struct sockaddr *) &sap, 1), | ||
| 967 | plen); | ||
| 968 | printf(" Scope:"); | ||
| 969 | switch (scope & IPV6_ADDR_SCOPE_MASK) { | ||
| 970 | case 0: | ||
| 971 | puts("Global"); | ||
| 972 | break; | ||
| 973 | case IPV6_ADDR_LINKLOCAL: | ||
| 974 | puts("Link"); | ||
| 975 | break; | ||
| 976 | case IPV6_ADDR_SITELOCAL: | ||
| 977 | puts("Site"); | ||
| 978 | break; | ||
| 979 | case IPV6_ADDR_COMPATv4: | ||
| 980 | puts("Compat"); | ||
| 981 | break; | ||
| 982 | case IPV6_ADDR_LOOPBACK: | ||
| 983 | puts("Host"); | ||
| 984 | break; | ||
| 985 | default: | ||
| 986 | puts("Unknown"); | ||
| 987 | } | ||
| 988 | } | ||
| 989 | } | ||
| 990 | fclose(f); | ||
| 991 | } | ||
| 992 | #else | ||
| 993 | static void ife_print6(struct interface *ptr) {} | ||
| 932 | #endif | 994 | #endif |
| 933 | 995 | ||
| 996 | |||
| 997 | static void ife_print(struct interface *ptr) | ||
| 998 | { | ||
| 999 | const struct aftype *ap; | ||
| 1000 | const struct hwtype *hw; | ||
| 1001 | int hf; | ||
| 1002 | int can_compress = 0; | ||
| 1003 | |||
| 934 | ap = get_afntype(ptr->addr.sa_family); | 1004 | ap = get_afntype(ptr->addr.sa_family); |
| 935 | if (ap == NULL) | 1005 | if (ap == NULL) |
| 936 | ap = get_afntype(0); | 1006 | ap = get_afntype(0); |
| @@ -947,9 +1017,11 @@ static void ife_print(struct interface *ptr) | |||
| 947 | printf("%-9.9s Link encap:%s ", ptr->name, hw->title); | 1017 | printf("%-9.9s Link encap:%s ", ptr->name, hw->title); |
| 948 | /* For some hardware types (eg Ash, ATM) we don't print the | 1018 | /* For some hardware types (eg Ash, ATM) we don't print the |
| 949 | hardware address if it's null. */ | 1019 | hardware address if it's null. */ |
| 950 | if (hw->print != NULL && (!(hw_null_address(hw, ptr->hwaddr) && | 1020 | if (hw->print != NULL |
| 951 | hw->suppress_null_addr))) | 1021 | && !(hw_null_address(hw, ptr->hwaddr) && hw->suppress_null_addr) |
| 1022 | ) { | ||
| 952 | printf("HWaddr %s ", hw->print((unsigned char *)ptr->hwaddr)); | 1023 | printf("HWaddr %s ", hw->print((unsigned char *)ptr->hwaddr)); |
| 1024 | } | ||
| 953 | #ifdef IFF_PORTSEL | 1025 | #ifdef IFF_PORTSEL |
| 954 | if (ptr->flags & IFF_PORTSEL) { | 1026 | if (ptr->flags & IFF_PORTSEL) { |
| 955 | printf("Media:%s", if_port_text[ptr->map.port] /* [0] */); | 1027 | printf("Media:%s", if_port_text[ptr->map.port] /* [0] */); |
| @@ -971,68 +1043,7 @@ static void ife_print(struct interface *ptr) | |||
| 971 | printf(" Mask:%s\n", ap->sprint(&ptr->netmask, 1)); | 1043 | printf(" Mask:%s\n", ap->sprint(&ptr->netmask, 1)); |
| 972 | } | 1044 | } |
| 973 | 1045 | ||
| 974 | #ifdef HAVE_AFINET6 | 1046 | ife_print6(ptr); |
| 975 | |||
| 976 | #define IPV6_ADDR_ANY 0x0000U | ||
| 977 | |||
| 978 | #define IPV6_ADDR_UNICAST 0x0001U | ||
| 979 | #define IPV6_ADDR_MULTICAST 0x0002U | ||
| 980 | #define IPV6_ADDR_ANYCAST 0x0004U | ||
| 981 | |||
| 982 | #define IPV6_ADDR_LOOPBACK 0x0010U | ||
| 983 | #define IPV6_ADDR_LINKLOCAL 0x0020U | ||
| 984 | #define IPV6_ADDR_SITELOCAL 0x0040U | ||
| 985 | |||
| 986 | #define IPV6_ADDR_COMPATv4 0x0080U | ||
| 987 | |||
| 988 | #define IPV6_ADDR_SCOPE_MASK 0x00f0U | ||
| 989 | |||
| 990 | #define IPV6_ADDR_MAPPED 0x1000U | ||
| 991 | #define IPV6_ADDR_RESERVED 0x2000U /* reserved address space */ | ||
| 992 | |||
| 993 | f = fopen_for_read(_PATH_PROCNET_IFINET6); | ||
| 994 | if (f != NULL) { | ||
| 995 | while (fscanf | ||
| 996 | (f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n", | ||
| 997 | addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4], | ||
| 998 | addr6p[5], addr6p[6], addr6p[7], &if_idx, &plen, &scope, | ||
| 999 | &dad_status, devname) != EOF | ||
| 1000 | ) { | ||
| 1001 | if (!strcmp(devname, ptr->name)) { | ||
| 1002 | sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", | ||
| 1003 | addr6p[0], addr6p[1], addr6p[2], addr6p[3], | ||
| 1004 | addr6p[4], addr6p[5], addr6p[6], addr6p[7]); | ||
| 1005 | inet_pton(AF_INET6, addr6, | ||
| 1006 | (struct sockaddr *) &sap.sin6_addr); | ||
| 1007 | sap.sin6_family = AF_INET6; | ||
| 1008 | printf(" inet6 addr: %s/%d", | ||
| 1009 | INET6_sprint((struct sockaddr *) &sap, 1), | ||
| 1010 | plen); | ||
| 1011 | printf(" Scope:"); | ||
| 1012 | switch (scope & IPV6_ADDR_SCOPE_MASK) { | ||
| 1013 | case 0: | ||
| 1014 | puts("Global"); | ||
| 1015 | break; | ||
| 1016 | case IPV6_ADDR_LINKLOCAL: | ||
| 1017 | puts("Link"); | ||
| 1018 | break; | ||
| 1019 | case IPV6_ADDR_SITELOCAL: | ||
| 1020 | puts("Site"); | ||
| 1021 | break; | ||
| 1022 | case IPV6_ADDR_COMPATv4: | ||
| 1023 | puts("Compat"); | ||
| 1024 | break; | ||
| 1025 | case IPV6_ADDR_LOOPBACK: | ||
| 1026 | puts("Host"); | ||
| 1027 | break; | ||
| 1028 | default: | ||
| 1029 | puts("Unknown"); | ||
| 1030 | } | ||
| 1031 | } | ||
| 1032 | } | ||
| 1033 | fclose(f); | ||
| 1034 | } | ||
| 1035 | #endif | ||
| 1036 | 1047 | ||
| 1037 | printf(" "); | 1048 | printf(" "); |
| 1038 | /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */ | 1049 | /* DONT FORGET TO ADD THE FLAGS IN ife_print_short, too */ |
| @@ -1124,11 +1135,11 @@ static void ife_print(struct interface *ptr) | |||
| 1124 | printf("\n R"); | 1135 | printf("\n R"); |
| 1125 | print_bytes_scaled(ptr->stats.rx_bytes, " T"); | 1136 | print_bytes_scaled(ptr->stats.rx_bytes, " T"); |
| 1126 | print_bytes_scaled(ptr->stats.tx_bytes, "\n"); | 1137 | print_bytes_scaled(ptr->stats.tx_bytes, "\n"); |
| 1127 | |||
| 1128 | } | 1138 | } |
| 1129 | 1139 | ||
| 1130 | if ((ptr->map.irq || ptr->map.mem_start || ptr->map.dma || | 1140 | if (ptr->map.irq || ptr->map.mem_start |
| 1131 | ptr->map.base_addr)) { | 1141 | || ptr->map.dma || ptr->map.base_addr |
| 1142 | ) { | ||
| 1132 | printf(" "); | 1143 | printf(" "); |
| 1133 | if (ptr->map.irq) | 1144 | if (ptr->map.irq) |
| 1134 | printf("Interrupt:%d ", ptr->map.irq); | 1145 | printf("Interrupt:%d ", ptr->map.irq); |
| @@ -1147,7 +1158,6 @@ static void ife_print(struct interface *ptr) | |||
| 1147 | bb_putchar('\n'); | 1158 | bb_putchar('\n'); |
| 1148 | } | 1159 | } |
| 1149 | 1160 | ||
| 1150 | |||
| 1151 | static int do_if_print(struct interface *ife) /*, int *opt_a)*/ | 1161 | static int do_if_print(struct interface *ife) /*, int *opt_a)*/ |
| 1152 | { | 1162 | { |
| 1153 | int res; | 1163 | int res; |
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index b29bf5a48..3f7fb4bef 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
| @@ -160,7 +160,7 @@ static ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n) | |||
| 160 | 160 | ||
| 161 | static int minix_bit(const char* a, unsigned i) | 161 | static int minix_bit(const char* a, unsigned i) |
| 162 | { | 162 | { |
| 163 | return a[i >> 3] & (1<<(i & 7)); | 163 | return a[i >> 3] & (1<<(i & 7)); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | static void minix_setbit(char *a, unsigned i) | 166 | static void minix_setbit(char *a, unsigned i) |
