From b7fd5f766870d5c1fb9d9363f0d8de42c3133fe0 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 5 Apr 2026 15:32:20 +0900 Subject: [PATCH] Fix public API: const refs, return by value, ip_address for addrs, remove void* dispatch --- picomap.cpp | 5 +- w6300/w6300.cpp | 268 +++++++++++++++--------------------------------- w6300/w6300.h | 44 ++++---- 3 files changed, 107 insertions(+), 210 deletions(-) diff --git a/picomap.cpp b/picomap.cpp index bf94e4f..36072f1 100644 --- a/picomap.cpp +++ b/picomap.cpp @@ -69,9 +69,8 @@ int main() { pico_unique_board_id_t uid; pico_get_unique_board_id(&uid); std::copy(uid.id, uid.id + 8, resp.board_id.begin()); - w6300::net_info info; - w6300::get_net_info(&info); - resp.mac = info.mac; + auto ninfo = w6300::get_net_info(); + resp.mac = ninfo.mac; send_bytes(encode_response(msg->message_id, resp)); break; } diff --git a/w6300/w6300.cpp b/w6300/w6300.cpp index 14776ef..19cbc5c 100644 --- a/w6300/w6300.cpp +++ b/w6300/w6300.cpp @@ -260,20 +260,6 @@ constexpr uint8_t PACK_REMAINED = static_cast(pack_info::remained); constexpr uint8_t PACK_COMPLETED = static_cast(pack_info::completed); constexpr uint8_t PACK_IPv6 = static_cast(pack_info::ipv6); -enum chip_ctl { - CW_SYS_LOCK, CW_SYS_UNLOCK, CW_GET_SYSLOCK, - CW_RESET_WIZCHIP, CW_INIT_WIZCHIP, - CW_GET_INTERRUPT, CW_CLR_INTERRUPT, CW_SET_INTRMASK, CW_GET_INTRMASK, - CW_SET_INTRTIME, CW_GET_INTRTIME, CW_SET_IEN, CW_GET_IEN, - CW_GET_ID, CW_GET_VER, CW_SET_SYSCLK, CW_GET_SYSCLK, - CW_RESET_PHY, CW_SET_PHYCONF, CW_GET_PHYCONF, CW_GET_PHYSTATUS, - CW_SET_PHYPOWMODE, CW_GET_PHYPOWMODE, CW_GET_PHYLINK -}; - -enum net_ctl { - CN_SET_NETINFO, CN_GET_NETINFO, CN_SET_NETMODE, CN_GET_NETMODE, - CN_SET_TIMEOUT, CN_GET_TIMEOUT, CN_SET_PREFER, CN_GET_PREFER, -}; enum sockint_kind { SIK_CONNECTED = 1, SIK_DISCONNECTED = 2, SIK_RECEIVED = 4, SIK_TIMEOUT = 8, SIK_SENT = 16, SIK_ALL = 0x1F }; @@ -950,101 +936,6 @@ static ipconf_mode ipmode_; static constexpr char CHIP_ID[] = "W6300"; -int8_t ctl_chip(chip_ctl cwtype, void* arg) { - uint8_t tmp = *(uint8_t*)arg; - uint8_t* ptmp[2] = {0, 0}; - switch (cwtype) { - case CW_SYS_LOCK: - if (tmp & SYS_CHIP_LOCK) CHIPLOCK(); - if (tmp & SYS_NET_LOCK) NETLOCK(); - if (tmp & SYS_PHY_LOCK) PHYLOCK(); - break; - case CW_SYS_UNLOCK: - if (tmp & SYS_CHIP_LOCK) CHIPUNLOCK(); - if (tmp & SYS_NET_LOCK) NETUNLOCK(); - if (tmp & SYS_PHY_LOCK) PHYUNLOCK(); - break; - case CW_GET_SYSLOCK: - *(uint8_t*)arg = getSYSR() >> 5; - break; - case CW_RESET_WIZCHIP: - soft_reset(); - break; - case CW_INIT_WIZCHIP: - if (arg) { - ptmp[0] = (uint8_t*)arg; - ptmp[1] = ptmp[0] + SOCK_COUNT; - } - return init_buffers(ptmp[0], ptmp[1]); - case CW_CLR_INTERRUPT: - clear_interrupt(*((intr_kind*)arg)); - break; - case CW_GET_INTERRUPT: - *((intr_kind*)arg) = get_interrupt(); - break; - case CW_SET_INTRMASK: - set_interrupt_mask(*((intr_kind*)arg)); - break; - case CW_GET_INTRMASK: - *((intr_kind*)arg) = get_interrupt_mask(); - break; - case CW_SET_INTRTIME: - setINTPTMR(*(uint16_t*)arg); - break; - case CW_GET_INTRTIME: - *(uint16_t*)arg = getINTPTMR(); - break; - case CW_GET_ID: - memcpy(arg, CHIP_ID, sizeof(CHIP_ID)); - break; - case CW_GET_VER: - *(uint16_t*)arg = getVER(); - break; - case CW_RESET_PHY: - reset_phy(); - break; - case CW_SET_PHYCONF: - set_phy_conf((phy_conf*)arg); - break; - case CW_GET_PHYCONF: - get_phy_conf((phy_conf*)arg); - break; - case CW_GET_PHYSTATUS: - break; - case CW_SET_PHYPOWMODE: - set_phy_power_mode(*(uint8_t*)arg); - break; - case CW_GET_PHYPOWMODE: - tmp = get_phy_power_mode(); - if ((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - case CW_GET_PHYLINK: - tmp = get_phy_link(); - if ((int8_t)tmp == -1) return -1; - *(uint8_t*)arg = tmp; - break; - default: - return -1; - } - return 0; -} - -int8_t ctl_net(net_ctl cntype, void* arg) { - switch (cntype) { - case CN_SET_NETINFO: set_net_info((net_info*)arg); break; - case CN_GET_NETINFO: get_net_info((net_info*)arg); break; - case CN_SET_NETMODE: set_net_mode(*(netmode_type*)arg); break; - case CN_GET_NETMODE: *(netmode_type*)arg = get_net_mode(); break; - case CN_SET_TIMEOUT: set_timeout((net_timeout*)arg); break; - case CN_GET_TIMEOUT: get_timeout((net_timeout*)arg); break; - case CN_SET_PREFER: setSLPSR(*(uint8_t*)arg); break; - case CN_GET_PREFER: *(uint8_t*)arg = getSLPSR(); break; - default: return -1; - } - return 0; -} - void soft_reset() { uint8_t gw[4], sn[4], sip[4], mac[6]; @@ -1065,9 +956,9 @@ void soft_reset() { if (islock & SYSR_NETL) NETLOCK(); } -int8_t init_buffers(uint8_t* txsize, uint8_t* rxsize) { +int8_t init_buffers(std::span txsize, std::span rxsize) { soft_reset(); - if (txsize) { + if (!txsize.empty()) { int8_t tmp = 0; for (int i = 0; i < SOCK_COUNT; i++) { tmp += txsize[i]; @@ -1075,7 +966,7 @@ int8_t init_buffers(uint8_t* txsize, uint8_t* rxsize) { } for (int i = 0; i < SOCK_COUNT; i++) setSn_TXBUF_SIZE(i, txsize[i]); } - if (rxsize) { + if (!rxsize.empty()) { int8_t tmp = 0; for (int i = 0; i < SOCK_COUNT; i++) { tmp += rxsize[i]; @@ -1129,36 +1020,40 @@ void reset_phy() { while (mdio_read(PHYRAR_BMCR) & BMCR_RST); } -void set_phy_conf(phy_conf* phyconf) { +void set_phy_conf(const phy_conf& phyconf) { uint16_t tmp = mdio_read(PHYRAR_BMCR); - if (phyconf->mode == PHY_MODE_TE) { + if (phyconf.mode == PHY_MODE_TE) { setPHYCR1(getPHYCR1() | PHYCR1_TE); setPHYCR0(PHYCR0_AUTO); } else { setPHYCR1(getPHYCR1() & ~PHYCR1_TE); - if (phyconf->mode == PHY_MODE_AUTONEGO) { + if (phyconf.mode == PHY_MODE_AUTONEGO) { tmp |= BMCR_ANE; } else { tmp &= ~(BMCR_ANE | BMCR_DPX | BMCR_SPD); - if (phyconf->duplex == PHY_DUPLEX_FULL) tmp |= BMCR_DPX; - if (phyconf->speed == PHY_SPEED_100) tmp |= BMCR_SPD; + if (phyconf.duplex == PHY_DUPLEX_FULL) tmp |= BMCR_DPX; + if (phyconf.speed == PHY_SPEED_100) tmp |= BMCR_SPD; } mdio_write(PHYRAR_BMCR, tmp); } } -void get_phy_conf(phy_conf* phyconf) { +phy_conf get_phy_conf() { + phy_conf result; uint16_t tmp = mdio_read(PHYRAR_BMCR); - phyconf->mode = (getPHYCR1() & PHYCR1_TE) ? PHY_MODE_TE : ((tmp & BMCR_ANE) ? PHY_MODE_AUTONEGO : PHY_MODE_MANUAL); - phyconf->duplex = (tmp & BMCR_DPX) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; - phyconf->speed = (tmp & BMCR_SPD) ? PHY_SPEED_100 : PHY_SPEED_10; + result.mode = (getPHYCR1() & PHYCR1_TE) ? PHY_MODE_TE : ((tmp & BMCR_ANE) ? PHY_MODE_AUTONEGO : PHY_MODE_MANUAL); + result.duplex = (tmp & BMCR_DPX) ? PHY_DUPLEX_FULL : PHY_DUPLEX_HALF; + result.speed = (tmp & BMCR_SPD) ? PHY_SPEED_100 : PHY_SPEED_10; + return result; } -void get_phy_status(phy_conf* phyconf) { +phy_conf get_phy_status() { + phy_conf result; uint8_t tmp = getPHYSR(); - phyconf->mode = (getPHYCR1() & PHYCR1_TE) ? PHY_MODE_TE : ((tmp & (1 << 5)) ? PHY_MODE_MANUAL : PHY_MODE_AUTONEGO); - phyconf->speed = (tmp & PHYSR_SPD) ? PHY_SPEED_10 : PHY_SPEED_100; - phyconf->duplex = (tmp & PHYSR_DPX) ? PHY_DUPLEX_HALF : PHY_DUPLEX_FULL; + result.mode = (getPHYCR1() & PHYCR1_TE) ? PHY_MODE_TE : ((tmp & (1 << 5)) ? PHY_MODE_MANUAL : PHY_MODE_AUTONEGO); + result.speed = (tmp & PHYSR_SPD) ? PHY_SPEED_10 : PHY_SPEED_100; + result.duplex = (tmp & PHYSR_DPX) ? PHY_DUPLEX_HALF : PHY_DUPLEX_FULL; + return result; } void set_phy_power_mode(uint8_t pmode) { @@ -1168,20 +1063,24 @@ void set_phy_power_mode(uint8_t pmode) { mdio_write(PHYRAR_BMCR, tmp); } -void set_net_info(net_info* p) { - setSHAR(p->mac.data()); setGAR(p->gw.data()); setSUBR(p->sn.data()); setSIPR(p->ip.data()); - setGA6R(p->gw6.data()); setSUB6R(p->sn6.data()); setLLAR(p->lla.data()); setGUAR(p->gua.data()); - memcpy(dns_, p->dns.data(), 4); - memcpy(dns6_, p->dns6.data(), 16); - ipmode_ = p->ipmode; +void set_net_info(const net_info& p) { + setSHAR(const_cast(p.mac.data())); setGAR(const_cast(p.gw.data())); + setSUBR(const_cast(p.sn.data())); setSIPR(const_cast(p.ip.data())); + setGA6R(const_cast(p.gw6.data())); setSUB6R(const_cast(p.sn6.data())); + setLLAR(const_cast(p.lla.data())); setGUAR(const_cast(p.gua.data())); + memcpy(dns_, p.dns.data(), 4); + memcpy(dns6_, p.dns6.data(), 16); + ipmode_ = p.ipmode; } -void get_net_info(net_info* p) { - getSHAR(p->mac.data()); getGAR(p->gw.data()); getSUBR(p->sn.data()); getSIPR(p->ip.data()); - getGA6R(p->gw6.data()); getSUB6R(p->sn6.data()); getLLAR(p->lla.data()); getGUAR(p->gua.data()); - memcpy(p->dns.data(), dns_, 4); - memcpy(p->dns6.data(), dns6_, 16); - p->ipmode = ipmode_; +net_info get_net_info() { + net_info p = {}; + getSHAR(p.mac.data()); getGAR(p.gw.data()); getSUBR(p.sn.data()); getSIPR(p.ip.data()); + getGA6R(p.gw6.data()); getSUB6R(p.sn6.data()); getLLAR(p.lla.data()); getGUAR(p.gua.data()); + memcpy(p.dns.data(), dns_, 4); + memcpy(p.dns6.data(), dns6_, 16); + p.ipmode = ipmode_; + return p; } void set_net_mode(netmode_type netmode) { @@ -1200,32 +1099,31 @@ netmode_type get_net_mode() { return (netmode_type)ret; } -void set_timeout(net_timeout* t) { - setRCR(t->s_retry_cnt); setRTR(t->s_time_100us); - setSLRCR(t->sl_retry_cnt); setSLRTR(t->sl_time_100us); +void set_timeout(const net_timeout& t) { + setRCR(t.s_retry_cnt); setRTR(t.s_time_100us); + setSLRCR(t.sl_retry_cnt); setSLRTR(t.sl_time_100us); } -void get_timeout(net_timeout* t) { - t->s_retry_cnt = getRCR(); t->s_time_100us = getRTR(); - t->sl_retry_cnt = getSLRCR(); t->sl_time_100us = getSLRTR(); +net_timeout get_timeout() { + return {getRCR(), getRTR(), getSLRCR(), getSLRTR()}; } -int8_t send_arp(arp_request* arp) { +int8_t send_arp(arp_request& arp) { uint8_t tmp; - if (arp->destinfo.len == 16) { setSLDIP6R(arp->destinfo.ip.data()); setSLCR(SLCR_ARP6); } - else { setSLDIP4R(arp->destinfo.ip.data()); setSLCR(SLCR_ARP4); } + if (arp.destinfo.len == 16) { setSLDIP6R(const_cast(arp.destinfo.ip.data())); setSLCR(SLCR_ARP6); } + else { setSLDIP4R(const_cast(arp.destinfo.ip.data())); setSLCR(SLCR_ARP4); } while (getSLCR()); while ((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); - if (tmp & (SLIR_ARP4 | SLIR_ARP6)) { getSLDHAR(arp->dha.data()); return 0; } + if (tmp & (SLIR_ARP4 | SLIR_ARP6)) { getSLDHAR(arp.dha.data()); return 0; } return -1; } -int8_t send_ping(ping_request* ping) { +int8_t send_ping(const ping_request& ping) { uint8_t tmp; - setPINGIDR(ping->id); setPINGSEQR(ping->seq); - if (ping->destinfo.len == 16) { setSLDIP6R(ping->destinfo.ip.data()); setSLCR(SLCR_PING6); } - else { setSLDIP4R(ping->destinfo.ip.data()); setSLCR(SLCR_PING4); } + setPINGIDR(ping.id); setPINGSEQR(ping.seq); + if (ping.destinfo.len == 16) { setSLDIP6R(const_cast(ping.destinfo.ip.data())); setSLCR(SLCR_PING6); } + else { setSLDIP4R(const_cast(ping.destinfo.ip.data())); setSLCR(SLCR_PING4); } while (getSLCR()); while ((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); @@ -1233,9 +1131,9 @@ int8_t send_ping(ping_request* ping) { return -1; } -int8_t send_dad(uint8_t* ipv6) { +int8_t send_dad(std::span ipv6) { uint8_t tmp; - setSLDIP6R(ipv6); setSLCR(SLCR_NS); + setSLDIP6R(const_cast(ipv6.data())); setSLCR(SLCR_NS); while (getSLCR()); while ((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); @@ -1243,16 +1141,16 @@ int8_t send_dad(uint8_t* ipv6) { return -1; } -int8_t send_slaac(prefix* prefix) { +int8_t send_slaac(prefix& pfx) { uint8_t tmp; setSLCR(SLCR_RS); while (getSLCR()); while ((tmp = getSLIR()) == 0x00); setSLIRCLR(~SLIR_RA); if (tmp & SLIR_RS) { - prefix->len = getPLR(); prefix->flag = getPFR(); - prefix->valid_lifetime = getVLTR(); prefix->preferred_lifetime = getPLTR(); - getPAR(prefix->prefix.data()); + pfx.len = getPLR(); pfx.flag = getPFR(); + pfx.valid_lifetime = getVLTR(); pfx.preferred_lifetime = getPLTR(); + getPAR(pfx.prefix.data()); return 0; } return -1; @@ -1268,11 +1166,11 @@ int8_t send_unsolicited() { return -1; } -int8_t get_prefix(prefix* prefix) { +int8_t get_prefix(prefix& pfx) { if (getSLIR() & SLIR_RA) { - prefix->len = getPLR(); prefix->flag = getPFR(); - prefix->valid_lifetime = getVLTR(); prefix->preferred_lifetime = getPLTR(); - getPAR(prefix->prefix.data()); + pfx.len = getPLR(); pfx.flag = getPFR(); + pfx.valid_lifetime = getVLTR(); pfx.preferred_lifetime = getPLTR(); + getPAR(pfx.prefix.data()); setSLIRCLR(SLIR_RA); } return -1; @@ -1395,26 +1293,27 @@ std::expected listen(socket_id sid) { return {}; } -std::expected connect(socket_id sid, uint8_t * addr, port_num port, uint8_t addrlen) { +std::expected connect(socket_id sid, const ip_address& addr, port_num port) { uint8_t sn = static_cast(sid); uint16_t p = static_cast(port); + uint8_t addrlen = addr.len; CHECK_SOCKNUM(); CHECK_TCPMODE(); CHECK_SOCKINIT(); - CHECK_IPZERO(addr, addrlen); + CHECK_IPZERO(addr.ip.data(), addrlen); if (p == 0) FAIL(port_zero); setSn_DPORTR(sn, p); if (addrlen == 16) { if (getSn_MR(sn) & 0x08) { - setSn_DIP6R(sn, addr); + setSn_DIP6R(sn, const_cast(addr.ip.data())); setSn_CR(sn, Sn_CR_CONNECT6); } else { FAIL(sock_mode); } } else { if (getSn_MR(sn) == Sn_MR_TCP6) FAIL(sock_mode); - setSn_DIPR(sn, addr); + setSn_DIPR(sn, const_cast(addr.ip.data())); setSn_CR(sn, Sn_CR_CONNECT); } while (getSn_CR(sn)); @@ -1523,10 +1422,11 @@ std::expected recv(socket_id sid, std::span buf) return len; } -std::expected sendto(socket_id sid, std::span buf, uint8_t * addr, port_num port, uint8_t addrlen) { +std::expected sendto(socket_id sid, std::span buf, const ip_address& addr, port_num port) { uint8_t sn = static_cast(sid); uint16_t p = static_cast(port); uint16_t len = buf.size(); + uint8_t addrlen = addr.len; uint8_t tmp = 0; uint8_t tcmd = Sn_CR_SEND; uint16_t freesize = 0; @@ -1545,14 +1445,14 @@ std::expected sendto(socket_id sid, std::span(addr.ip.data())); tcmd = Sn_CR_SEND6; } else { FAIL(sock_mode); } } else if (addrlen == 4) { if (tmp == Sn_MR_UDP6 || tmp == Sn_MR_IPRAW6) FAIL(sock_mode); - setSn_DIPR(sn, addr); + setSn_DIPR(sn, const_cast(addr.ip.data())); tcmd = Sn_CR_SEND; } else { FAIL(ip_invalid); @@ -1590,7 +1490,7 @@ std::expected sendto(socket_id sid, std::span recvfrom(socket_id sid, std::span buf, uint8_t * addr, port_num *port, uint8_t *addrlen) { +std::expected recvfrom(socket_id sid, std::span buf, ip_address& addr, port_num& port) { uint8_t sn = static_cast(sid); uint16_t len = buf.size(); uint8_t mr; @@ -1632,11 +1532,10 @@ std::expected recvfrom(socket_id sid, std::span b case Sn_MR_UDP4: case Sn_MR_UDP6: case Sn_MR_UDPD: - if (addr == 0) FAIL(arg); sock_pack_info[sn] = head[0] & 0xF8; - if (sock_pack_info[sn] & PACK_IPv6) *addrlen = 16; - else *addrlen = 4; - recv_data(sn, addr, *addrlen); + if (sock_pack_info[sn] & PACK_IPv6) addr.len = 16; + else addr.len = 4; + recv_data(sn, addr.ip.data(), addr.len); setSn_CR(sn, Sn_CR_RECV); while (getSn_CR(sn)); break; @@ -1657,11 +1556,10 @@ std::expected recvfrom(socket_id sid, std::span b case Sn_MR_IPRAW6: case Sn_MR_IPRAW4: if (sock_remained_size[sn] == 0) { - if (*addr == 0) FAIL(arg); sock_pack_info[sn] = head[0] & 0xF8; - if (sock_pack_info[sn] & PACK_IPv6) *addrlen = 16; - else *addrlen = 4; - recv_data(sn, addr, *addrlen); + if (sock_pack_info[sn] & PACK_IPv6) addr.len = 16; + else addr.len = 4; + recv_data(sn, addr.ip.data(), addr.len); setSn_CR(sn, Sn_CR_RECV); while (getSn_CR(sn)); } @@ -1675,9 +1573,8 @@ std::expected recvfrom(socket_id sid, std::span b sock_remained_size[sn] = pack_len; sock_pack_info[sn] |= PACK_FIRST; if ((getSn_MR(sn) & 0x03) == 0x02) { - if (port == 0) FAIL(arg); recv_data(sn, head, 2); - *port = static_cast((((uint16_t)head[0]) << 8) + head[1]); + port = static_cast((((uint16_t)head[0]) << 8) + head[1]); setSn_CR(sn, Sn_CR_RECV); while (getSn_CR(sn)); } @@ -1736,18 +1633,19 @@ void init_critical_section() { void init() { pio_frame_end(); - uint8_t memsize[2][8] = {{4, 4, 4, 4, 4, 4, 4, 4}, {4, 4, 4, 4, 4, 4, 4, 4}}; - ctl_chip(CW_INIT_WIZCHIP, (void *)memsize); + std::array txsize = {4, 4, 4, 4, 4, 4, 4, 4}; + std::array rxsize = {4, 4, 4, 4, 4, 4, 4, 4}; + init_buffers(txsize, rxsize); } bool check() { return getCIDR() == 0x6300; } -void init_net(net_info net_info) { - uint8_t syslock = SYS_NET_LOCK; - ctl_chip(CW_SYS_UNLOCK, &syslock); - ctl_net(CN_SET_NETINFO, (void *)&net_info); +void init_net(const net_info& info) { + CHIPUNLOCK(); + NETUNLOCK(); + set_net_info(info); } std::expected set_socket_io_mode(socket_id sid, sock_io_mode mode) { diff --git a/w6300/w6300.h b/w6300/w6300.h index ccbd61f..8d19586 100644 --- a/w6300/w6300.h +++ b/w6300/w6300.h @@ -188,36 +188,36 @@ void init_critical_section(); void reset(); void init(); bool check(); -void init_net(net_info info); +void init_net(const net_info& info); -void soft_reset(); -int8_t init_buffers(uint8_t* txsize, uint8_t* rxsize); -void clear_interrupt(intr_kind intr); +void soft_reset(); +int8_t init_buffers(std::span txsize, std::span rxsize); +void clear_interrupt(intr_kind intr); intr_kind get_interrupt(); -void set_interrupt_mask(intr_kind intr); +void set_interrupt_mask(intr_kind intr); intr_kind get_interrupt_mask(); int8_t get_phy_link(); int8_t get_phy_power_mode(); -void reset_phy(); -void set_phy_conf(phy_conf* conf); -void get_phy_conf(phy_conf* conf); -void get_phy_status(phy_conf* conf); -void set_phy_power_mode(uint8_t pmode); +void reset_phy(); +void set_phy_conf(const phy_conf& conf); +phy_conf get_phy_conf(); +phy_conf get_phy_status(); +void set_phy_power_mode(uint8_t pmode); -void set_net_info(net_info* info); -void get_net_info(net_info* info); +void set_net_info(const net_info& info); +net_info get_net_info(); void set_net_mode(netmode_type mode); netmode_type get_net_mode(); -void set_timeout(net_timeout* timeout); -void get_timeout(net_timeout* timeout); +void set_timeout(const net_timeout& timeout); +net_timeout get_timeout(); -int8_t send_arp(arp_request* arp); -int8_t send_ping(ping_request* ping); -int8_t send_dad(uint8_t* ipv6); -int8_t send_slaac(prefix* pfx); +int8_t send_arp(arp_request& arp); +int8_t send_ping(const ping_request& ping); +int8_t send_dad(std::span ipv6); +int8_t send_slaac(prefix& pfx); int8_t send_unsolicited(); -int8_t get_prefix(prefix* pfx); +int8_t get_prefix(prefix& pfx); std::expected open_socket(socket_id sn, protocol proto, port_num port, sock_flag flag); std::expected close(socket_id sn); @@ -226,9 +226,9 @@ std::expected disconnect(socket_id sn); std::expected send(socket_id sn, std::span buf); std::expected recv(socket_id sn, std::span buf); -std::expected connect(socket_id sn, uint8_t* addr, port_num port, uint8_t addrlen); -std::expected sendto(socket_id sn, std::span buf, uint8_t* addr, port_num port, uint8_t addrlen); -std::expected recvfrom(socket_id sn, std::span buf, uint8_t* addr, port_num* port, uint8_t* addrlen); +std::expected connect(socket_id sn, const ip_address& addr, port_num port); +std::expected sendto(socket_id sn, std::span buf, const ip_address& addr, port_num port); +std::expected recvfrom(socket_id sn, std::span buf, ip_address& addr, port_num& port); std::expected set_socket_io_mode(socket_id sn, sock_io_mode mode); sock_io_mode get_socket_io_mode(socket_id sn);