| 126 | } |
| 127 | |
| 128 | static void |
| 129 | bridge_interfaces(int s, const char *prefix) |
| 130 | { |
| 131 | struct ifbifconf bifc; |
| 132 | struct ifbreq *req; |
| 133 | char *inbuf = NULL, *ninbuf; |
| 134 | char *p, *pad; |
| 135 | int i, len = 8192; |
| 136 | |
| 137 | pad = strdup(prefix); |
| 138 | if (pad == NULL) |
| 139 | err(1, "strdup"); |
| 140 | /* replace the prefix with whitespace */ |
| 141 | for (p = pad; *p != '\0'; p++) { |
| 142 | if(isprint(*p)) |
| 143 | *p = ' '; |
| 144 | } |
| 145 | |
| 146 | for (;;) { |
| 147 | #ifndef FSTACK |
| 148 | ninbuf = realloc(inbuf, len); |
| 149 | #else |
| 150 | ninbuf = rte_malloc(NULL, len, 0); |
| 151 | #endif |
| 152 | if (ninbuf == NULL) |
| 153 | err(1, "unable to allocate interface buffer"); |
| 154 | bifc.ifbic_len = len; |
| 155 | bifc.ifbic_buf = inbuf = ninbuf; |
| 156 | if (do_cmd(s, BRDGGIFS, &bifc, sizeof(bifc), 0) < 0) |
| 157 | err(1, "unable to get interface list"); |
| 158 | if ((bifc.ifbic_len + sizeof(*req)) < len) |
| 159 | break; |
| 160 | len *= 2; |
| 161 | } |
| 162 | |
| 163 | for (i = 0; i < bifc.ifbic_len / sizeof(*req); i++) { |
| 164 | req = bifc.ifbic_req + i; |
| 165 | printf("%s%s ", prefix, req->ifbr_ifsname); |
| 166 | printb("flags", req->ifbr_ifsflags, IFBIFBITS); |
| 167 | printf("\n"); |
| 168 | |
| 169 | printf("%s", pad); |
| 170 | printf("ifmaxaddr %u", req->ifbr_addrmax); |
| 171 | printf(" port %u priority %u", req->ifbr_portno, |
| 172 | req->ifbr_priority); |
| 173 | printf(" path cost %u", req->ifbr_path_cost); |
| 174 | |
| 175 | if (req->ifbr_ifsflags & IFBIF_STP) { |
| 176 | if (req->ifbr_proto < nitems(stpproto)) |
| 177 | printf(" proto %s", stpproto[req->ifbr_proto]); |
| 178 | else |
| 179 | printf(" <unknown proto %d>", |
| 180 | req->ifbr_proto); |
| 181 | |
| 182 | printf("\n%s", pad); |
| 183 | if (req->ifbr_role < nitems(stproles)) |
| 184 | printf("role %s", stproles[req->ifbr_role]); |
| 185 | else |
no test coverage detected