MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / at_getsockopt

Function at_getsockopt

components/net/at/at_socket/at_socket.c:1245–1295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1243}
1244
1245int at_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlen)
1246{
1247 struct at_socket *sock;
1248 int32_t timeout;
1249
1250 if (optval == RT_NULL || optlen == RT_NULL)
1251 {
1252 LOG_E("AT getsocketopt input option value or option length error!");
1253 rt_set_errno(EFAULT);
1254 return -1;
1255 }
1256
1257 sock = at_get_socket(socket);
1258 if (sock == RT_NULL)
1259 {
1260 rt_set_errno(ENXIO);
1261 return -1;
1262 }
1263
1264 switch (level)
1265 {
1266 case SOL_SOCKET:
1267 switch (optname)
1268 {
1269 case SO_RCVTIMEO:
1270 timeout = sock->recv_timeout;
1271 ((struct timeval *)(optval))->tv_sec = (timeout) / 1000U;
1272 ((struct timeval *)(optval))->tv_usec = (timeout % 1000U) * 1000U;
1273 break;
1274
1275 case SO_SNDTIMEO:
1276 timeout = sock->send_timeout;
1277 ((struct timeval *) optval)->tv_sec = timeout / 1000U;
1278 ((struct timeval *) optval)->tv_usec = (timeout % 1000U) * 1000U;
1279 break;
1280
1281 default:
1282 LOG_E("AT socket (%d) not support option name : %d.", socket, optname);
1283 rt_set_errno(EPERM);
1284 return -1;
1285 }
1286 break;
1287
1288 default:
1289 LOG_E("AT socket (%d) not support option level : %d.", socket, level);
1290 rt_set_errno(EPERM);
1291 return -1;
1292 }
1293
1294 return 0;
1295}
1296
1297int at_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen)
1298{

Callers

nothing calls this directly

Calls 2

rt_set_errnoFunction · 0.85
at_get_socketFunction · 0.85

Tested by

no test coverage detected