From: kosmirror <kos...@us...> - 2025-07-22 14:32:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via aa71e4bf968432dd95d8b1bc083e50d7fac9adda (commit) from 4fbcde321da028f4d98ceb51839a53d6cf60917e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aa71e4bf968432dd95d8b1bc083e50d7fac9adda Author: QuzarDC <qu...@co...> Date: Fri Jul 18 23:16:58 2025 -0400 net: Replace `arch/types.h` types with stdint. ----------------------------------------------------------------------- Summary of changes: include/kos/net.h | 178 ++++++++++++++++++++++----------------------- kernel/net/net_arp.c | 49 +++++++------ kernel/net/net_core.c | 3 +- kernel/net/net_crc.c | 12 +-- kernel/net/net_dhcp.c | 45 ++++++------ kernel/net/net_dhcp.h | 34 ++++----- kernel/net/net_icmp.c | 47 ++++++------ kernel/net/net_icmp.h | 14 ++-- kernel/net/net_icmp6.c | 87 +++++++++++----------- kernel/net/net_icmp6.h | 140 +++++++++++++++++------------------ kernel/net/net_input.c | 7 +- kernel/net/net_ipv4.c | 61 ++++++++-------- kernel/net/net_ipv4.h | 36 ++++----- kernel/net/net_ipv4_frag.c | 34 ++++----- kernel/net/net_ipv6.c | 25 ++++--- kernel/net/net_ipv6.h | 20 ++--- kernel/net/net_multicast.c | 11 +-- kernel/net/net_ndp.c | 19 ++--- kernel/net/net_tcp.c | 18 ++--- kernel/net/net_thd.c | 9 ++- kernel/net/net_thd.h | 5 +- kernel/net/net_udp.c | 42 +++++------ 22 files changed, 452 insertions(+), 444 deletions(-) diff --git a/include/kos/net.h b/include/kos/net.h index 47363535..a23929af 100644 --- a/include/kos/net.h +++ b/include/kos/net.h @@ -21,9 +21,9 @@ #define __KOS_NET_H #include <sys/cdefs.h> +#include <stdint.h> __BEGIN_DECLS -#include <arch/types.h> #include <sys/queue.h> #include <netinet/in.h> @@ -65,28 +65,28 @@ typedef struct knetif { int index; /** \brief Internal device ID (for whatever the driver wants) */ - uint32 dev_id; + uint32_t dev_id; /** \brief Interface flags */ - uint32 flags; + uint32_t flags; /** \brief The device's MAC address */ - uint8 mac_addr[6]; + uint8_t mac_addr[6]; /** \brief The device's IP address (if any) */ - uint8 ip_addr[4]; + uint8_t ip_addr[4]; /** \brief The device's netmask */ - uint8 netmask[4]; + uint8_t netmask[4]; /** \brief The device's gateway's IP address */ - uint8 gateway[4]; + uint8_t gateway[4]; /** \brief The device's broadcast address */ - uint8 broadcast[4]; + uint8_t broadcast[4]; /** \brief The device's DNS server address */ - uint8 dns[4]; + uint8_t dns[4]; /** \brief The device's MTU */ int mtu; @@ -104,7 +104,7 @@ typedef struct knetif { struct in6_addr ip6_gateway; /** \brief Default MTU over IPv6 */ - uint32 mtu6; + uint32_t mtu6; /** \brief Default hop limit over IPv6 */ int hop_limit; @@ -117,31 +117,31 @@ typedef struct knetif { \param self The network device in question. \return 0 on success, <0 on failure. */ - int (*if_detect)(struct knetif * self); + int (*if_detect)(struct knetif *self); /** \brief Initialize the device. \param self The network device in question. \return 0 on success, <0 on failure. */ - int (*if_init)(struct knetif * self); + int (*if_init)(struct knetif *self); /** \brief Shutdown the device. \param self The network device in question. \return 0 on success, <0 on failure. */ - int (*if_shutdown)(struct knetif * self); + int (*if_shutdown)(struct knetif *self); /** \brief Start the device (after init or stop). \param self The network device in question. \return 0 on success, <0 on failure. */ - int (*if_start)(struct knetif * self); + int (*if_start)(struct knetif *self); /** \brief Stop (hibernate) the device. \param self The network device in question. \return 0 on success, <0 on failure */ - int (*if_stop)(struct knetif * self); + int (*if_stop)(struct knetif *self); /** \brief Queue a packet for transmission. \param self The network device in question. @@ -152,20 +152,20 @@ typedef struct knetif { \retval NETIF_TX_ERROR On general failure. \retval NETIF_TX_AGAIN If non-blocking and we must block to send. */ - int (*if_tx)(struct knetif * self, const uint8 * data, int len, + int (*if_tx)(struct knetif *self, const uint8_t *data, int len, int blocking); /** \brief Commit any queued output packets. \param self The network device in question. \return 0 on success, <0 on failure. */ - int (*if_tx_commit)(struct knetif * self); + int (*if_tx_commit)(struct knetif *self); /** \brief Poll for queued receive packets, if necessary. \param self The network device in question. \return 0 on success, <0 on failure. */ - int (*if_rx_poll)(struct knetif * self); + int (*if_rx_poll)(struct knetif *self); /** \brief Set flags; you should generally manipulate flags through here so that the driver gets a chance to act on the info. @@ -173,14 +173,14 @@ typedef struct knetif { \param flags_and Bitmask to and with the flags. \param flags_or Bitmask to or with the flags. */ - int (*if_set_flags)(struct knetif * self, uint32 flags_and, uint32 flags_or); + int (*if_set_flags)(struct knetif *self, uint32_t flags_and, uint32_t flags_or); /** \brief Set the device's multicast list. \param self The network device in question. \param list The list of MAC addresses (6 * count bytes). \param count The number of addresses in list. */ - int (*if_set_mc)(struct knetif *self, const uint8 *list, int count); + int (*if_set_mc)(struct knetif *self, const uint8_t *list, int count); } netif_t; /** \defgroup net_drivers_flags netif_t Flags @@ -237,16 +237,16 @@ LIST_HEAD(netif_list, knetif); \ingroup networking_ipv4 */ typedef struct ip_hdr_s { - uint8 version_ihl; /**< \brief IP version and header length */ - uint8 tos; /**< \brief Type of Service */ - uint16 length; /**< \brief Length */ - uint16 packet_id; /**< \brief Packet ID */ - uint16 flags_frag_offs; /**< \brief Flags and fragment offset */ - uint8 ttl; /**< \brief Time to live */ - uint8 protocol; /**< \brief IP protocol */ - uint16 checksum; /**< \brief IP checksum */ - uint32 src; /**< \brief Source IP address */ - uint32 dest; /**< \brief Destination IP address */ + uint8_t version_ihl; /**< \brief IP version and header length */ + uint8_t tos; /**< \brief Type of Service */ + uint16_t length; /**< \brief Length */ + uint16_t packet_id; /**< \brief Packet ID */ + uint16_t flags_frag_offs; /**< \brief Flags and fragment offset */ + uint8_t ttl; /**< \brief Time to live */ + uint8_t protocol; /**< \brief IP protocol */ + uint16_t checksum; /**< \brief IP checksum */ + uint32_t src; /**< \brief Source IP address */ + uint32_t dest; /**< \brief Destination IP address */ } __packed ip_hdr_t; /** \defgroup networking_ipv6 IPv6 @@ -259,14 +259,14 @@ typedef struct ip_hdr_s { \ingroup networking_ipv6 */ typedef struct ipv6_hdr_s { - uint8 version_lclass; /**< \brief Version and low-order class + uint8_t version_lclass; /**< \brief Version and low-order class byte */ - uint8 hclass_lflow; /**< \brief High-order class byte, low-order + uint8_t hclass_lflow; /**< \brief High-order class byte, low-order flow byte */ - uint16 lclass; /**< \brief Low-order class byte */ - uint16 length; /**< \brief Length */ - uint8 next_header; /**< \brief Next header type */ - uint8 hop_limit; /**< \brief Hop limit */ + uint16_t lclass; /**< \brief Low-order class byte */ + uint16_t length; /**< \brief Length */ + uint8_t next_header; /**< \brief Next header type */ + uint8_t hop_limit; /**< \brief Hop limit */ struct in6_addr src_addr; /**< \brief Source IP address */ struct in6_addr dst_addr; /**< \brief Destination IP address */ } __packed ipv6_hdr_t; @@ -303,8 +303,8 @@ void net_arp_shutdown(void); \retval 0 On success. \retval -1 Error allocating memory. */ -int net_arp_insert(netif_t *nif, const uint8 mac[6], const uint8 ip[4], - uint64 timestamp); +int net_arp_insert(netif_t *nif, const uint8_t mac[6], const uint8_t ip[4], + uint64_t timestamp); /** \brief Look up an entry from the ARP cache. \ingroup networking_arp @@ -326,8 +326,8 @@ int net_arp_insert(netif_t *nif, const uint8 mac[6], const uint8 ip[4], \retval -2 Address not found, query generated. \retval -3 Error allocating memory. */ -int net_arp_lookup(netif_t *nif, const uint8 ip_in[4], uint8 mac_out[6], - const ip_hdr_t *pkt, const uint8 *data, int data_size); +int net_arp_lookup(netif_t *nif, const uint8_t ip_in[4], uint8_t mac_out[6], + const ip_hdr_t *pkt, const uint8_t *data, int data_size); /** \brief Do a reverse ARP lookup. \ingroup networking_arp @@ -342,7 +342,7 @@ int net_arp_lookup(netif_t *nif, const uint8 ip_in[4], uint8 mac_out[6], \retval 0 On success. \retval -1 On failure. */ -int net_arp_revlookup(netif_t *nif, uint8 ip_out[4], const uint8 mac_in[6]); +int net_arp_revlookup(netif_t *nif, uint8_t ip_out[4], const uint8_t mac_in[6]); /** \brief Receive an ARP packet and process it (called by net_input). \ingroup networking_arp @@ -353,7 +353,7 @@ int net_arp_revlookup(netif_t *nif, uint8 ip_out[4], const uint8 mac_in[6]); \retval 0 On success (no error conditions defined). */ -int net_arp_input(netif_t *nif, const uint8 *pkt, int len); +int net_arp_input(netif_t *nif, const uint8_t *pkt, int len); /** \brief Generate an ARP who-has query on the given device. \ingroup networking_arp @@ -363,7 +363,7 @@ int net_arp_input(netif_t *nif, const uint8 *pkt, int len); \retval 0 On success (no error conditions defined). */ -int net_arp_query(netif_t *nif, const uint8 ip[4]); +int net_arp_query(netif_t *nif, const uint8_t ip[4]); /***** net_input.c *********************************************************/ @@ -377,7 +377,7 @@ int net_arp_query(netif_t *nif, const uint8 ip[4]); \return 0 on success, <0 on failure. */ -typedef int (*net_input_func)(netif_t *nif, const uint8 *pkt, int len); +typedef int (*net_input_func)(netif_t *nif, const uint8_t *pkt, int len); /** \brief Where will input packets be routed? \ingroup networking_drivers @@ -397,7 +397,7 @@ extern net_input_func net_input_target; \return 0 on success, <0 on failure. */ -int net_input(netif_t *device, const uint8 *data, int len); +int net_input(netif_t *device, const uint8_t *data, int len); /** \brief Setup a network input target. \ingroup networking_drivers @@ -431,8 +431,8 @@ net_input_func net_input_set_target(net_input_func t); \param data Any data in the packet. \param len The length of the data, in bytes. */ -typedef void (*net_echo_cb)(const uint8 *ip, uint16 seq, uint64 delta_us, - uint8 ttl, const uint8 *data, size_t len); +typedef void (*net_echo_cb)(const uint8_t *ip, uint16_t seq, uint64_t delta_us, + uint8_t ttl, const uint8_t *data, size_t len); /** \brief Where will we handle possibly notifying the user of ping replies? \ingroup networking_icmp @@ -451,8 +451,8 @@ extern net_echo_cb net_icmp_echo_cb; \return 0 on success, <0 on failure. */ -int net_icmp_send_echo(netif_t *net, const uint8 ipaddr[4], uint16 ident, - uint16 seq, const uint8 *data, size_t size); +int net_icmp_send_echo(netif_t *net, const uint8_t ipaddr[4], uint16_t ident, + uint16_t seq, const uint8_t *data, size_t size); /** \defgroup networking_icmp_unreach Unreachable Values \brief Valid values for net_icmp_send_dest_unreach(). @@ -473,7 +473,7 @@ int net_icmp_send_echo(netif_t *net, const uint8 ipaddr[4], uint16 ident, \return 0 on success, <0 on failure. */ -int net_icmp_send_dest_unreach(netif_t *net, uint8 code, const uint8 *msg); +int net_icmp_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *msg); /** \brief Valid values for the code in the net_icmp_send_time_exceeded() function. @@ -490,7 +490,7 @@ int net_icmp_send_dest_unreach(netif_t *net, uint8 code, const uint8 *msg); \return 0 on success, <0 on failure. */ -int net_icmp_send_time_exceeded(netif_t *net, uint8 code, const uint8 *msg); +int net_icmp_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *msg); /***** net_ipv4.c *********************************************************/ @@ -503,12 +503,12 @@ int net_icmp_send_time_exceeded(netif_t *net, uint8 code, const uint8 *msg); \headerfile kos/net.h */ typedef struct net_ipv4_stats { - uint32 pkt_sent; /** \brief Packets sent out successfully */ - uint32 pkt_send_failed; /** \brief Packets that failed to send */ - uint32 pkt_recv; /** \brief Packets received successfully */ - uint32 pkt_recv_bad_size; /** \brief Packets of a bad size */ - uint32 pkt_recv_bad_chksum; /** \brief Packets with a bad checksum */ - uint32 pkt_recv_bad_proto; /** \brief Packets with an unknown proto */ + uint32_t pkt_sent; /** \brief Packets sent out successfully */ + uint32_t pkt_send_failed; /** \brief Packets that failed to send */ + uint32_t pkt_recv; /** \brief Packets received successfully */ + uint32_t pkt_recv_bad_size; /** \brief Packets of a bad size */ + uint32_t pkt_recv_bad_chksum; /** \brief Packets with a bad checksum */ + uint32_t pkt_recv_bad_proto; /** \brief Packets with an unknown proto */ } net_ipv4_stats_t; /** \brief Retrieve statistics from the IPv4 layer. @@ -526,7 +526,7 @@ net_ipv4_stats_t net_ipv4_get_stats(void); \return The address, in host byte order. */ -uint32 net_ipv4_address(const uint8 addr[4]); +uint32_t net_ipv4_address(const uint8_t addr[4]); /** \brief Parse an IP address that is packet into a uint32 into an array of the individual bytes. @@ -535,7 +535,7 @@ uint32 net_ipv4_address(const uint8 addr[4]); \param addr The full address, in host byte order. \param out The output buffer. */ -void net_ipv4_parse_address(uint32 addr, uint8 out[4]); +void net_ipv4_parse_address(uint32_t addr, uint8_t out[4]); /***** net_icmp6.c ********************************************************/ @@ -555,8 +555,8 @@ void net_ipv4_parse_address(uint32 addr, uint8 out[4]); \param data Any data in the packet. \param len The length of the data, in bytes. */ -typedef void (*net6_echo_cb)(const struct in6_addr *ip, uint16 seq, - uint64 delta_us, uint8 hlim, const uint8 *data, +typedef void (*net6_echo_cb)(const struct in6_addr *ip, uint16_t seq, + uint64_t delta_us, uint8_t hlim, const uint8_t *data, size_t len); /** \brief Where will we handle possibly notifying the user of ping replies? @@ -576,8 +576,8 @@ extern net6_echo_cb net_icmp6_echo_cb; \return 0 on success, <0 on failure. */ -int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16 ident, - uint16 seq, const uint8 *data, size_t size); +int net_icmp6_send_echo(netif_t *net, const struct in6_addr *dst, uint16_t ident, + uint16_t seq, const uint8_t *data, size_t size); /** \brief Send a Neighbor Solicitation packet on the specified device. \ingroup networking_icmpv6 @@ -641,7 +641,7 @@ int net_icmp6_send_rsol(netif_t *net); \return 0 on success, <0 on failure. */ -int net_icmp6_send_dest_unreach(netif_t *net, uint8 code, const uint8 *ppkt, +int net_icmp6_send_dest_unreach(netif_t *net, uint8_t code, const uint8_t *ppkt, size_t psz); /** \defgroup networking_icmpv6_time_exceeded Time Exceeded Codes @@ -666,7 +666,7 @@ int net_icmp6_send_dest_unreach(netif_t *net, uint8 code, const uint8 *ppkt, \return 0 on success, <0 on failure. */ -int net_icmp6_send_time_exceeded(netif_t *net, uint8 code, const uint8 *ppkt, +int net_icmp6_send_time_exceeded(netif_t *net, uint8_t code, const uint8_t *ppkt, size_t psz); /** \defgroup networking_icmpv6_param_problem Parameter Problem Codes @@ -690,8 +690,8 @@ int net_icmp6_send_time_exceeded(netif_t *net, uint8 code, const uint8 *ppkt, \return 0 on success, <0 on failure. */ -int net_icmp6_send_param_prob(netif_t *net, uint8 code, uint32 ptr, - const uint8 *ppkt, size_t psz); +int net_icmp6_send_param_prob(netif_t *net, uint8_t code, uint32_t ptr, + const uint8_t *ppkt, size_t psz); /***** net_ipv6.c *********************************************************/ @@ -704,12 +704,12 @@ int net_icmp6_send_param_prob(netif_t *net, uint8 code, uint32 ptr, \headerfile kos/net.h */ typedef struct net_ipv6_stats { - uint32 pkt_sent; /**< \brief Packets sent out successfully */ - uint32 pkt_send_failed; /**< \brief Packets that failed to send */ - uint32 pkt_recv; /**< \brief Packets received successfully */ - uint32 pkt_recv_bad_size; /**< \brief Packets of a bad size */ - uint32 pkt_recv_bad_proto; /**< \brief Packets with an unknown proto */ - uint32 pkt_recv_bad_ext; /**< \brief Packets with an unknown hdr */ + uint32_t pkt_sent; /**< \brief Packets sent out successfully */ + uint32_t pkt_send_failed; /**< \brief Packets that failed to send */ + uint32_t pkt_recv; /**< \brief Packets received successfully */ + uint32_t pkt_recv_bad_size; /**< \brief Packets of a bad size */ + uint32_t pkt_recv_bad_proto; /**< \brief Packets with an unknown proto */ + uint32_t pkt_recv_bad_ext; /**< \brief Packets with an unknown hdr */ } net_ipv6_stats_t; /** \brief Retrieve statistics from the IPv6 layer. @@ -747,7 +747,7 @@ void net_ndp_gc(void); \param unsol Was this unsolicited? \return 0 on success, <0 on failure. */ -int net_ndp_insert(netif_t *nif, const uint8 mac[6], const struct in6_addr *ip, +int net_ndp_insert(netif_t *nif, const uint8_t mac[6], const struct in6_addr *ip, int unsol); /** \brief Look up an entry from the NDP cache. @@ -765,8 +765,8 @@ int net_ndp_insert(netif_t *nif, const uint8 mac[6], const struct in6_addr *ip, \param data_size The size of data. \return 0 on success, <0 on failure. */ -int net_ndp_lookup(netif_t *net, const struct in6_addr *ip, uint8 mac_out[6], - const ipv6_hdr_t *pkt, const uint8 *data, int data_size); +int net_ndp_lookup(netif_t *net, const struct in6_addr *ip, uint8_t mac_out[6], + const ipv6_hdr_t *pkt, const uint8_t *data, int data_size); /** @} */ @@ -786,12 +786,12 @@ int net_ndp_lookup(netif_t *net, const struct in6_addr *ip, uint8 mac_out[6], \headerfile kos/net.h */ typedef struct net_udp_stats { - uint32 pkt_sent; /**< \brief Packets sent out successfully */ - uint32 pkt_send_failed; /**< \brief Packets that failed to send */ - uint32 pkt_recv; /**< \brief Packets received successfully */ - uint32 pkt_recv_bad_size; /**< \brief Packets of a bad size */ - uint32 pkt_recv_bad_chksum; /**< \brief Packets with a bad checksum */ - uint32 pkt_recv_no_sock; /**< \brief Packets with to a closed port */ + uint32_t pkt_sent; /**< \brief Packets sent out successfully */ + uint32_t pkt_send_failed; /**< \brief Packets that failed to send */ + uint32_t pkt_recv; /**< \brief Packets received successfully */ + uint32_t pkt_recv_bad_size; /**< \brief Packets of a bad size */ + uint32_t pkt_recv_bad_chksum; /**< \brief Packets with a bad checksum */ + uint32_t pkt_recv_no_sock; /**< \brief Packets with to a closed port */ } net_udp_stats_t; /** \brief Retrieve statistics from the UDP layer. @@ -844,7 +844,7 @@ void net_tcp_shutdown(void); \return The calculated CRC-32. */ -uint32 net_crc32le(const uint8 *data, int size); +uint32_t net_crc32le(const uint8_t *data, int size); /** \brief Calculate a "big-endian" CRC-32 over a block of data. @@ -853,7 +853,7 @@ uint32 net_crc32le(const uint8 *data, int size); \return The calculated CRC-32. */ -uint32 net_crc32be(const uint8 *data, int size); +uint32_t net_crc32be(const uint8_t *data, int size); /** \brief Calculate a CRC16-CCITT over a block of data. @@ -869,7 +869,7 @@ uint32 net_crc32be(const uint8 *data, int size); \return The calculated CRC16-CCITT. */ -uint16 net_crc16ccitt(const uint8 *data, int size, uint16 start); +uint16_t net_crc16ccitt(const uint8_t *data, int size, uint16_t start); /** @} */ @@ -889,7 +889,7 @@ uint16 net_crc16ccitt(const uint8 *data, int size, uint16 start); \param mac The MAC address to add. \return 0 on success, <0 on failure. */ -int net_multicast_add(const uint8 mac[6]); +int net_multicast_add(const uint8_t mac[6]); /** \brief Delete a entry from our multicast list. @@ -899,7 +899,7 @@ int net_multicast_add(const uint8 mac[6]); \param mac The MAC address to add. \return 0 on success, <0 on failure. */ -int net_multicast_del(const uint8 mac[6]); +int net_multicast_del(const uint8_t mac[6]); /** \brief Check if an address is on the multicast list. \param mac The MAC address to check for. @@ -907,7 +907,7 @@ int net_multicast_del(const uint8 mac[6]); \retval 1 The address is in the list. \retval -1 On error. ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |