MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / alloc_socket

Function alloc_socket

components/net/at/at_socket/at_socket.c:471–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471static struct at_socket *alloc_socket(enum at_socket_type type)
472{
473 extern struct netdev *netdev_default;
474 struct netdev *netdev = RT_NULL;
475 struct at_device *device = RT_NULL;
476
477 if (netdev_default && netdev_is_up(netdev_default) &&
478 netdev_family_get(netdev_default) == AF_AT)
479 {
480 netdev = netdev_default;
481 }
482 else
483 {
484 /* get network interface device by protocol family AF_AT */
485 netdev = netdev_get_by_family(AF_AT);
486 if (netdev == RT_NULL)
487 {
488 return RT_NULL;
489 }
490 }
491
492 device = at_device_get_by_name(AT_DEVICE_NAMETYPE_NETDEV, netdev->name);
493 if (device == RT_NULL)
494 {
495 return RT_NULL;
496 }
497
498 return alloc_socket_by_device(device, type);
499}
500
501static void at_recv_notice_cb(struct at_socket *sock, at_socket_evt_t event, const char *buff, size_t bfsz);
502static void at_closed_notice_cb(struct at_socket *sock, at_socket_evt_t event, const char *buff, size_t bfsz);

Callers 1

at_socketFunction · 0.70

Calls 3

netdev_family_getFunction · 0.85
netdev_get_by_familyFunction · 0.85
alloc_socket_by_deviceFunction · 0.85

Tested by

no test coverage detected