PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
net.c
Go to the documentation of this file.
1#include "net.h"
2
3#include "local/local.h"
4#include "socket_family.h"
5
6#include <kernel/fs/dentry.h>
7#include <kernel/fs/mount.h>
8#include <kernel/fs/path.h>
9#include <kernel/fs/sysfs.h>
10#include <kernel/log/log.h>
11#include <kernel/log/panic.h>
13#include <sys/io.h>
14
15static mount_t* mount;
16
18{
19 return REF(mount);
20}
21
22static uint64_t net_init(void)
23{
26 if (mount == NULL)
27 {
28 return ERR;
29 }
30
31 if (net_local_init() == ERR)
32 {
33 UNREF(mount);
34 return ERR;
35 }
36
37 return 0;
38}
39
40static void net_deinit(void)
41{
43
45
46 UNREF(mount);
47}
48
50{
51 switch (event->type)
52 {
54 net_init();
55 break;
57 net_deinit();
58 break;
59 default:
60 break;
61 }
62
63 return 0;
64}
65
66MODULE_INFO("Networking", "Kai Norberg", "Provides networking and socket IPC functionality", OS_VERSION, "MIT",
67 "BOOT_ALWAYS");
@ MODE_ALL_PERMS
Definition path.h:87
@ MODE_DIRECTORY
Definition path.h:84
#define MODULE_INFO(_name, _author, _description, _version, _licence, _deviceTypes)
Macro to define module information.
Definition module.h:200
@ MODULE_EVENT_LOAD
Definition module.h:239
@ MODULE_EVENT_UNLOAD
Definition module.h:245
#define REF(ptr)
Increment reference count.
Definition ref.h:65
#define UNREF(ptr)
Decrement reference count.
Definition ref.h:80
@ MOUNT_PROPAGATE_PARENT
Propagate the mount to parent namespaces.
Definition io.h:490
@ MOUNT_PROPAGATE_CHILDREN
Propagate the mount to child namespaces.
Definition io.h:491
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
void net_local_deinit(void)
Deinitialize the local networking subsystem.
Definition local.c:534
uint64_t net_local_init(void)
Initialize the local networking subsystem.
Definition local.c:517
void socket_family_unregister_all(void)
Unregister all socket families.
mount_t * net_get_mount(void)
Retrieve the mount for the networking subsystem.
Definition net.c:17
static void net_deinit(void)
Definition net.c:40
uint64_t _module_procedure(const module_event_t *event)
Definition net.c:49
static mount_t * mount
Definition net.c:15
static uint64_t net_init(void)
Definition net.c:22
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
module_event_type_t type
Definition module.h:268
Mount structure.
Definition mount.h:44
mount_t * sysfs_mount_new(const path_t *parent, const char *name, namespace_t *ns, mount_flags_t flags, mode_t mode, const superblock_ops_t *superblockOps)
Mount a new instance of SysFS.
Definition sysfs.c:104