21 #include "modules/system/network-stack/NetworkStack.h" 22 #include "pedigree/kernel/Log.h" 23 #include "pedigree/kernel/compiler.h" 24 #include "pedigree/kernel/machine/Device.h" 25 #include "pedigree/kernel/machine/Network.h" 26 #include "pedigree/kernel/network/IpAddress.h" 27 #include "pedigree/kernel/network/MacAddress.h" 28 #include "pedigree/kernel/utilities/utility.h" 32 void cdi_cpp_net_register(
void* void_pdev,
struct cdi_net_device* device);
33 void cdi_net_receive(
struct cdi_net_device* device,
void* buffer,
size_t size);
34 struct cdi_net_device* cdi_net_get_device(
int num);
43 uint64_t mac = m_Device->mac;
44 m_StationInfo.mac.setMac(reinterpret_cast<uint16_t*>(&mac),
false);
55 uint64_t mac = m_Device->mac;
56 m_StationInfo.mac.setMac(reinterpret_cast<uint16_t*>(&mac),
false);
67 struct cdi_net_driver *driver =
reinterpret_cast<struct cdi_net_driver *
>(m_Device->dev.driver);
70 driver->send_packet(m_Device, reinterpret_cast<void*>(buffer), nBytes);
84 if (m_StationInfo.dnsServers)
85 delete [] m_StationInfo.dnsServers;
88 m_StationInfo.ipv4 = info.ipv4;
89 NOTICE(
"cdi-net: Setting ipv4, " << info.ipv4.toString() <<
", " << m_StationInfo.ipv4.toString() <<
"...");
91 m_StationInfo.ipv6 = info.ipv6;
92 m_StationInfo.nIpv6Addresses = info.nIpv6Addresses;
93 NOTICE(
"cdi-net: Assigning " <<
Dec << info.nIpv6Addresses <<
Hex <<
" IPv6 addresses.");
95 m_StationInfo.subnetMask = info.subnetMask;
96 NOTICE(
"cdi-net: Setting subnet mask, " << info.subnetMask.toString() <<
", " << m_StationInfo.subnetMask.toString() <<
"...");
98 NOTICE(
"cdi-net: Setting gateway, " << info.
gateway.toString() <<
", " << m_StationInfo.
gateway.toString() <<
"...");
101 m_StationInfo.dnsServers = info.dnsServers;
103 NOTICE(
"cdi-net: Setting DNS servers [" <<
Dec << m_StationInfo.
nDnsServers <<
Hex <<
" servers being set]...");
108 EXPORTED_PUBLIC void cdi_cpp_net_register(
void* void_pdev,
struct cdi_net_device* device)
121 EXPORTED_PUBLIC void cdi_net_receive(
struct cdi_net_device* device,
void* buffer,
size_t size)
123 auto f = [&] (
Device *p) {
126 if (p->getSpecificType() ==
"CDI NIC")
129 if (pNet->getCdiDevice() == device)
139 auto c = pedigree_std::make_callable(f);
virtual const StationInfo & getStationInfo()
virtual bool setStationInfo(const StationInfo &info)
static void addToRoot(Device *device)
IpAddress gateway
Automatically calculated?
void receive(size_t nBytes, uintptr_t packet, Network *pCard, uint32_t offset)
size_t nDnsServers
Can contain IPv6 addresses.
virtual void setSpecificType(String str)
virtual bool send(size_t nBytes, uintptr_t buffer)
CdiNet(struct cdi_net_device *device)
static void foreach(Callback callback, Device *root=0)
static NetworkStack & instance()
void registerDevice(Network *pDevice)