XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
aunet.h File Reference
#include <stdint.h>
#include <aurora.h>
#include <Fs/vfs.h>
#include <Net/ipv6.h>
Include dependency graph for aunet.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _netdev_
 

Macros

#define NETDEV_TYPE_ETHERNET   1
 
#define NETDEV_TYPE_802_11   2
 
#define NETDEV_TYPE_BLUETOOTH   3
 
#define NETDEV_TYPE_LOOPBACK   4
 
#define MAKE_IP(a, b, c, d)    ((uint32_t)(d) << 24 | (uint32_t)(c) << 16 | (uint32_t)(b) << 8 | (uint32_t)(a))
 
#define htonl(l)   ((((l) & 0xFF) << 24) | (((l) & 0xFF00) << 8) | (((l) & 0xFF0000) >> 8) | (((l) & 0xFF000000) >> 24))
 
#define htons(s)   ((((s) & 0xFF) << 8) | (((s) & 0xFF00) >> 8))
 
#define ntohl(l)   htonl((l))
 
#define ntohs(s)   htons((s))
 
#define AUNET_GET_HARDWARE_ADDRESS   0x100
 
#define AUNET_SET_IPV4_ADDRESS   0x101
 
#define AUNET_GET_IPV4_ADDRESS   0x102
 
#define AUNET_GET_GATEWAY_ADDRESS   0x103
 
#define AUNET_SET_GATEWAY_ADDRESS   0x104
 
#define AUNET_GET_SUBNET_MASK   0x105
 
#define AUNET_SET_SUBNET_MASK   0x106
 
#define AUNET_GET_LINK_STATUS   0x107
 
#define AUNET_GET_IPV6_ADDRESS   0x108
 
#define AUNET_SET_IPV6_ADDRESS   0x109
 
#define AUNET_GET_IPV6_GATEWAY   0x10A
 
#define AUNET_SET_IPV6_GATEWAY   0x10B
 
#define AUNET_GET_IPV6_PREFIX   0x10C
 
#define AUNET_SET_IPV6_PREFIX   0x10D
 
#define WIFI_SCAN   0x140
 
#define WIFI_GET_SCAN   0x141
 
#define WIFI_CONNECT   0x142
 
#define WIFI_DISCONNECT   0x143
 
#define WIFI_GET_STATUS   0x144
 
#define WIFI_UPLINK   0x145
 
#define AU_DNS_MAX4   4
 
#define AU_DNS_MAX6   2
 

Typedefs

typedef struct _netdev_ AuNetworkDevice
 

Functions

void AuInitialiseNet ()
 AuInitialiseNet – initialise network data structures.
 
AU_EXTERN AU_EXPORT AuVFSNode * AuAddNetAdapter (AuVFSNode *netfs, char *name)
 AuAddNetAdapter – add a net adapter to the adapter list.
 
AU_EXTERN AU_EXPORT int AuRemoveNetAdapter (char *name)
 AuRemoveNetAdapter – the driver behind an adapter is going away. The node itself stays (open handles and the stack may still point at it) but becomes a dead interface: writes are dropped, the link is down, and nothing points into the departing driver any more. A later AuAddNetAdapter with the same name revives it.
 
AU_EXTERN AU_EXPORT AuVFSNode * AuGetNetworkAdapter (char *name)
 AuGetNetworkAdapter – get a network adapter.
 
AuVFSNode * AuNetworkRoute (uint32_t address)
 AuNetworkRoute – select NIC for an IPv4 destination.
 
AuVFSNode * AuNetworkRoute6 (const ip6_addr *address)
 
int AuAddrIsLocal4 (uint32_t address)
 
int AuAddrIsLocal6 (const ip6_addr *address)
 
AU_EXTERN AU_EXPORT void AuNetAddConnectedRoute4 (AuVFSNode *nic, const char *ifname)
 
AU_EXTERN AU_EXPORT void AuNetAddConnectedRoute6 (AuVFSNode *nic, const char *ifname)
 
AU_EXTERN AU_EXPORT void AuNetAddDefaultRoute4 (AuVFSNode *nic, const char *ifname)
 
AU_EXTERN AU_EXPORT void AuNetAddDefaultRoute6 (AuVFSNode *nic, const char *ifname)
 
AU_EXTERN AU_EXPORT void AuDnsAddServer4 (uint32_t addr)
 
AU_EXTERN AU_EXPORT void AuDnsSetServer4 (int index, uint32_t addr)
 
int AuDnsGetServer4 (int index, uint32_t *out)
 
AU_EXTERN AU_EXPORT void AuDnsAddServer6 (const ip6_addr *addr)
 
AU_EXTERN AU_EXPORT void AuDnsSetServer6 (int index, const ip6_addr *addr)
 
int AuDnsGetServer6 (int index, ip6_addr *out)
 
AU_EXTERN AU_EXPORT void AuNetRegisterRxPoll (void(*fn)(void))
 
AU_EXTERN AU_EXPORT void AuNetRxPoll (void)
 

Macro Definition Documentation

◆ AU_DNS_MAX4

#define AU_DNS_MAX4   4

◆ AU_DNS_MAX6

#define AU_DNS_MAX6   2

◆ AUNET_GET_GATEWAY_ADDRESS

#define AUNET_GET_GATEWAY_ADDRESS   0x103

◆ AUNET_GET_HARDWARE_ADDRESS

#define AUNET_GET_HARDWARE_ADDRESS   0x100

◆ AUNET_GET_IPV4_ADDRESS

#define AUNET_GET_IPV4_ADDRESS   0x102

◆ AUNET_GET_IPV6_ADDRESS

#define AUNET_GET_IPV6_ADDRESS   0x108

◆ AUNET_GET_IPV6_GATEWAY

#define AUNET_GET_IPV6_GATEWAY   0x10A

◆ AUNET_GET_IPV6_PREFIX

#define AUNET_GET_IPV6_PREFIX   0x10C

◆ AUNET_GET_LINK_STATUS

#define AUNET_GET_LINK_STATUS   0x107

◆ AUNET_GET_SUBNET_MASK

#define AUNET_GET_SUBNET_MASK   0x105

◆ AUNET_SET_GATEWAY_ADDRESS

#define AUNET_SET_GATEWAY_ADDRESS   0x104

◆ AUNET_SET_IPV4_ADDRESS

#define AUNET_SET_IPV4_ADDRESS   0x101

◆ AUNET_SET_IPV6_ADDRESS

#define AUNET_SET_IPV6_ADDRESS   0x109

◆ AUNET_SET_IPV6_GATEWAY

#define AUNET_SET_IPV6_GATEWAY   0x10B

◆ AUNET_SET_IPV6_PREFIX

#define AUNET_SET_IPV6_PREFIX   0x10D

◆ AUNET_SET_SUBNET_MASK

#define AUNET_SET_SUBNET_MASK   0x106

◆ htonl

#define htonl (   l)    ((((l) & 0xFF) << 24) | (((l) & 0xFF00) << 8) | (((l) & 0xFF0000) >> 8) | (((l) & 0xFF000000) >> 24))

◆ htons

#define htons (   s)    ((((s) & 0xFF) << 8) | (((s) & 0xFF00) >> 8))

◆ MAKE_IP

#define MAKE_IP (   a,
  b,
  c,
  d 
)     ((uint32_t)(d) << 24 | (uint32_t)(c) << 16 | (uint32_t)(b) << 8 | (uint32_t)(a))

◆ NETDEV_TYPE_802_11

#define NETDEV_TYPE_802_11   2

◆ NETDEV_TYPE_BLUETOOTH

#define NETDEV_TYPE_BLUETOOTH   3

◆ NETDEV_TYPE_ETHERNET

#define NETDEV_TYPE_ETHERNET   1

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ NETDEV_TYPE_LOOPBACK

#define NETDEV_TYPE_LOOPBACK   4

◆ ntohl

#define ntohl (   l)    htonl((l))

◆ ntohs

#define ntohs (   s)    htons((s))

◆ WIFI_CONNECT

#define WIFI_CONNECT   0x142

◆ WIFI_DISCONNECT

#define WIFI_DISCONNECT   0x143

◆ WIFI_GET_SCAN

#define WIFI_GET_SCAN   0x141

◆ WIFI_GET_STATUS

#define WIFI_GET_STATUS   0x144

◆ WIFI_SCAN

#define WIFI_SCAN   0x140

◆ WIFI_UPLINK

#define WIFI_UPLINK   0x145

Typedef Documentation

◆ AuNetworkDevice

typedef struct _netdev_ AuNetworkDevice

Function Documentation

◆ AuAddNetAdapter()

AU_EXTERN AU_EXPORT AuVFSNode * AuAddNetAdapter ( AuVFSNode *  netfs,
char *  name 
)

AuAddNetAdapter – add a net adapter to the adapter list.

◆ AuAddrIsLocal4()

int AuAddrIsLocal4 ( uint32_t  address)
extern

◆ AuAddrIsLocal6()

int AuAddrIsLocal6 ( const ip6_addr *  address)
extern

◆ AuDnsAddServer4()

AU_EXTERN AU_EXPORT void AuDnsAddServer4 ( uint32_t  addr)

◆ AuDnsAddServer6()

AU_EXTERN AU_EXPORT void AuDnsAddServer6 ( const ip6_addr *  addr)

◆ AuDnsGetServer4()

int AuDnsGetServer4 ( int  index,
uint32_t *  out 
)
extern

◆ AuDnsGetServer6()

int AuDnsGetServer6 ( int  index,
ip6_addr *  out 
)
extern

◆ AuDnsSetServer4()

AU_EXTERN AU_EXPORT void AuDnsSetServer4 ( int  index,
uint32_t  addr 
)

◆ AuDnsSetServer6()

AU_EXTERN AU_EXPORT void AuDnsSetServer6 ( int  index,
const ip6_addr *  addr 
)

◆ AuGetNetworkAdapter()

AU_EXTERN AU_EXPORT AuVFSNode * AuGetNetworkAdapter ( char *  name)

AuGetNetworkAdapter – get a network adapter.

Parameters
name– adapter name

◆ AuInitialiseNet()

void AuInitialiseNet ( )
extern

AuInitialiseNet – initialise network data structures.

◆ AuNetAddConnectedRoute4()

AU_EXTERN AU_EXPORT void AuNetAddConnectedRoute4 ( AuVFSNode *  nic,
const char *  ifname 
)

◆ AuNetAddConnectedRoute6()

AU_EXTERN AU_EXPORT void AuNetAddConnectedRoute6 ( AuVFSNode *  nic,
const char *  ifname 
)

◆ AuNetAddDefaultRoute4()

AU_EXTERN AU_EXPORT void AuNetAddDefaultRoute4 ( AuVFSNode *  nic,
const char *  ifname 
)

◆ AuNetAddDefaultRoute6()

AU_EXTERN AU_EXPORT void AuNetAddDefaultRoute6 ( AuVFSNode *  nic,
const char *  ifname 
)

◆ AuNetRegisterRxPoll()

AU_EXTERN AU_EXPORT void AuNetRegisterRxPoll ( void(*)(void)  fn)

◆ AuNetRxPoll()

AU_EXTERN AU_EXPORT void AuNetRxPoll ( void  )

◆ AuNetworkRoute()

AuVFSNode * AuNetworkRoute ( uint32_t  address)
extern

AuNetworkRoute – select NIC for an IPv4 destination.

Parameters
address– Address to consider (MAKE_IP/wire or host-order sockaddr)

◆ AuNetworkRoute6()

AuVFSNode * AuNetworkRoute6 ( const ip6_addr *  address)
extern

◆ AuRemoveNetAdapter()

AU_EXTERN AU_EXPORT int AuRemoveNetAdapter ( char *  name)

AuRemoveNetAdapter – the driver behind an adapter is going away. The node itself stays (open handles and the stack may still point at it) but becomes a dead interface: writes are dropped, the link is down, and nothing points into the departing driver any more. A later AuAddNetAdapter with the same name revives it.

Returns
0 if it existed, -1 otherwise