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

Method getsockopt

source/kernel/knativesocket.cpp:1285–1418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1283}
1284
1285U32 KNativeSocketObject::getsockopt(KThread* thread, const KFileDescriptorPtr& fd, U32 level, U32 name, U32 value, U32 len_address) {
1286 KMemory* memory = thread->memory;
1287 socklen_t len = (socklen_t)memory->readd(len_address);
1288 S32 result = 0;
1289 U32 retrievedValue = 0;
1290
1291 if (level == K_SOL_SOCKET) {
1292 if (name == K_SO_RCVBUF) {
1293 if (len!=4)
1294 kpanic("KNativeSocketObject::getsockopt SO_RCVBUF expecting len of 4");
1295 result = ::getsockopt(this->nativeSocket, SOL_SOCKET, SO_RCVBUF, (char*)&retrievedValue, &len);
1296 if (!result) {
1297 memory->writed(value, retrievedValue);
1298 }
1299 } else if (name == K_SO_SNDBUF) {
1300 if (len != 4)
1301 kpanic("KNativeSocketObject::getsockopt SO_SNDBUF expecting len of 4");
1302 result = ::getsockopt(this->nativeSocket, SOL_SOCKET, SO_SNDBUF, (char*)&retrievedValue, &len);
1303 if (!result) {
1304 memory->writed(value, retrievedValue);
1305 }
1306 } else if (name == K_SO_ERROR) {
1307 if (len != 4)
1308 kpanic("KNativeSocketObject::getsockopt SO_ERROR expecting len of 4");
1309 memory->writed(value, this->error);
1310 retrievedValue = this->error;
1311 } else if (name == K_SO_TYPE) {
1312 if (len != 4)
1313 kpanic("KNativeSocketObject::getsockopt K_SO_TYPE expecting len of 4");
1314 memory->writed(value, this->type);
1315 retrievedValue = this->type;
1316 } else if (name == K_SO_OOBINLINE) {
1317 if (len != 4)
1318 kpanic("KNativeSocketObject::getsockopt SO_OOBINLINE expecting len of 4");
1319 result = ::getsockopt(this->nativeSocket, SOL_SOCKET, SO_OOBINLINE, (char*)&retrievedValue, &len);
1320 if (!result) {
1321 memory->writed(value, retrievedValue);
1322 }
1323 } else if (name == K_SO_BROADCAST) {
1324 if (len != 4)
1325 kpanic("KNativeSocketObject::getsockopt SO_BROADCAST expecting len of 4");
1326 U32 result = 0;
1327 result = ::getsockopt(this->nativeSocket, SOL_SOCKET, SO_BROADCAST, (char*)&retrievedValue, &len);
1328 if (!result) {
1329 memory->writed(value, retrievedValue);
1330 }
1331 } else if (name == K_SO_RCVTIMEO) {
1332 if (len != 8)
1333 kpanic("KNativeSocketObject::getsockopt SO_RCVTIMEO expecting len of 8");
1334#ifdef BOXEDWINE_MSVC
1335 len = 4;
1336 DWORD v = 0;
1337 result = ::getsockopt(this->nativeSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&v, &len);
1338
1339 U32 sec = v / 1000;
1340 U32 usec = (v % 1000) * 1000;
1341#else
1342 struct timeval v;

Callers

nothing calls this directly

Calls 5

kpanicFunction · 0.85
kwarn_fmtFunction · 0.85
handleNativeSocketErrorFunction · 0.85
readdMethod · 0.45
writedMethod · 0.45

Tested by

no test coverage detected