summaryrefslogtreecommitdiff
path: root/extmod/modnetwork.h
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-12-14 16:29:30 +1100
committerDamien George <damien@micropython.org>2022-12-15 17:40:06 +1100
commit5f8f32f917479d5fdd052292eae64f9d43b07217 (patch)
treeb27e2fe3276bb0237d5592649c0f543c9020b726 /extmod/modnetwork.h
parent7f71057a89322d8a0b82b94abbe04b86a74f69da (diff)
extmod/modnetwork: Use a type protocol to implement NIC functions.
This was previously implemented by adding additional members to the mp_obj_type_t defined for each NIC, which is difficult to do cleanly with the new object type slots mechanism. The way this works is also not supported on GCC 8.x and below. Instead replace it with the type protocol, which is a much simpler way of achieving the same thing. This affects the WizNet (in non-LWIP mode) and Nina NIC drivers. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/modnetwork.h')
-rw-r--r--extmod/modnetwork.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/extmod/modnetwork.h b/extmod/modnetwork.h
index 55ee4eb4d..a28ec6e42 100644
--- a/extmod/modnetwork.h
+++ b/extmod/modnetwork.h
@@ -61,10 +61,7 @@ mp_obj_t mod_network_nic_ifconfig(struct netif *netif, size_t n_args, const mp_o
struct _mod_network_socket_obj_t;
-typedef struct _mod_network_nic_type_t {
- // Ensure that this struct is big enough to hold any type size.
- mp_obj_full_type_t base;
-
+typedef struct _mod_network_nic_protocol_t {
// API for non-socket operations
int (*gethostbyname)(mp_obj_t nic, const char *name, mp_uint_t len, uint8_t *ip_out);
@@ -82,12 +79,12 @@ typedef struct _mod_network_nic_type_t {
int (*setsockopt)(struct _mod_network_socket_obj_t *socket, mp_uint_t level, mp_uint_t opt, const void *optval, mp_uint_t optlen, int *_errno);
int (*settimeout)(struct _mod_network_socket_obj_t *socket, mp_uint_t timeout_ms, int *_errno);
int (*ioctl)(struct _mod_network_socket_obj_t *socket, mp_uint_t request, mp_uint_t arg, int *_errno);
-} mod_network_nic_type_t;
+} mod_network_nic_protocol_t;
typedef struct _mod_network_socket_obj_t {
mp_obj_base_t base;
mp_obj_t nic;
- mod_network_nic_type_t *nic_type;
+ mod_network_nic_protocol_t *nic_protocol;
uint32_t domain : 5;
uint32_t type : 5;
uint32_t proto : 5;