| 276 | ****************************************************************************/ |
| 277 | |
| 278 | int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype) |
| 279 | { |
| 280 | FAR struct net_driver_s **last; |
| 281 | FAR char devfmt_str[IFNAMSIZ]; |
| 282 | FAR const char *devfmt; |
| 283 | uint32_t flags = 0; |
| 284 | uint16_t pktsize = 0; |
| 285 | uint8_t llhdrlen = 0; |
| 286 | int devnum; |
| 287 | #ifdef CONFIG_NETDEV_IFINDEX |
| 288 | int ifindex; |
| 289 | #endif |
| 290 | |
| 291 | if (dev != NULL) |
| 292 | { |
| 293 | /* Set the protocol used by the device and the size of the link |
| 294 | * header used by this protocol. |
| 295 | */ |
| 296 | |
| 297 | switch (lltype) |
| 298 | { |
| 299 | #ifdef CONFIG_NET_LOOPBACK |
| 300 | case NET_LL_LOOPBACK: /* Local loopback */ |
| 301 | llhdrlen = 0; |
| 302 | pktsize = NET_LO_PKTSIZE; |
| 303 | devfmt = NETDEV_LO_FORMAT; |
| 304 | flags = IFF_LOOPBACK; |
| 305 | break; |
| 306 | #endif |
| 307 | |
| 308 | #ifdef CONFIG_NET_ETHERNET |
| 309 | case NET_LL_ETHERNET: /* Ethernet */ |
| 310 | llhdrlen = ETH_HDRLEN; |
| 311 | pktsize = CONFIG_NET_ETH_PKTSIZE; |
| 312 | devfmt = NETDEV_ETH_FORMAT; |
| 313 | flags = IFF_BROADCAST | IFF_MULTICAST; |
| 314 | break; |
| 315 | #endif |
| 316 | |
| 317 | #ifdef CONFIG_DRIVERS_IEEE80211 |
| 318 | case NET_LL_IEEE80211: /* IEEE 802.11 */ |
| 319 | llhdrlen = ETH_HDRLEN; |
| 320 | pktsize = CONFIG_NET_ETH_PKTSIZE; |
| 321 | devfmt = NETDEV_WLAN_FORMAT; |
| 322 | flags = IFF_BROADCAST | IFF_MULTICAST; |
| 323 | break; |
| 324 | #endif |
| 325 | |
| 326 | #ifdef CONFIG_NET_CAN |
| 327 | case NET_LL_CAN: /* CAN bus */ |
| 328 | dev->d_llhdrlen = 0; |
| 329 | dev->d_pktsize = NET_CAN_PKTSIZE; |
| 330 | devfmt = NETDEV_CAN_FORMAT; |
| 331 | flags = IFF_NOARP; |
| 332 | break; |
| 333 | #endif |
| 334 | |
| 335 | #ifdef CONFIG_NET_BLUETOOTH |
no test coverage detected