MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ksocket

Function ksocket

source/kernel/ksocket.cpp:54–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54U32 ksocket(U32 domain, U32 type, U32 protocol) {
55 if (domain==K_AF_UNIX) {
56 std::shared_ptr<KUnixSocketObject> kSocket = std::make_shared<KUnixSocketObject>(domain, type, protocol);
57 KFileDescriptorPtr result = KThread::currentThread()->process->allocFileDescriptor(kSocket, K_O_RDWR, 0, -1, 0);
58 return result->handle;
59 } else if (domain == K_AF_NETLINK) {
60 std::shared_ptr<KNetLinkObject> kSocket = std::make_shared<KNetLinkObject>(domain, type, protocol);
61 KFileDescriptorPtr result = KThread::currentThread()->process->allocFileDescriptor(kSocket, K_O_RDWR, 0, -1, 0);
62 return result->handle;
63 } else if (domain == K_AF_INET) {
64 std::shared_ptr<KNativeSocketObject> s = std::make_shared<KNativeSocketObject>(domain, type, protocol);
65 if (s->error) {
66 return s->error;
67 } else {
68 KFileDescriptorPtr result = KThread::currentThread()->process->allocFileDescriptor(s, K_O_RDWR, 0, -1, 0);
69 return result->handle;
70 }
71 }
72 return -K_EAFNOSUPPORT;
73}
74
75#define IS_NOT_SOCKET(fd) (fd->kobject->type!=KTYPE_NATIVE_SOCKET && fd->kobject->type!=KTYPE_UNIX_SOCKET)
76

Callers 3

syscall_socketcallFunction · 0.85
syscall_socketFunction · 0.85
ksocketpairFunction · 0.85

Calls 1

allocFileDescriptorMethod · 0.80

Tested by

no test coverage detected