| 52 | } |
| 53 | |
| 54 | U32 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 |
no test coverage detected