MCPcopy Create free account
hub / github.com/qilingframework/qiling / get_opened_socket

Function get_opened_socket

qiling/os/posix/syscall/socket.py:164–183  ·  view source on GitHub ↗

Retrieve opened socket by its fd index. In case of a error, the appropriate error number is returned.

(os: QlOsPosix, fd: int)

Source from the content-addressed store, hash-verified

162
163
164def get_opened_socket(os: QlOsPosix, fd: int) -> Union[ql_socket, int]:
165 """Retrieve opened socket by its fd index. In case of a error, the
166 appropriate error number is returned.
167 """
168
169 # fd out of range?
170 if fd not in range(NR_OPEN):
171 return -EBADF
172
173 sock = os.fd[fd]
174
175 # not an opened file?
176 if sock is None:
177 return -EBADF
178
179 # not a socket?
180 if not isinstance(sock, ql_socket):
181 return -ENOTSOCK
182
183 return sock
184
185
186def ql_syscall_socket(ql: Qiling, domain: int, socktype: int, protocol: int):

Callers 14

ql_syscall_connectFunction · 0.85
ql_syscall_getsockoptFunction · 0.85
ql_syscall_setsockoptFunction · 0.85
ql_syscall_shutdownFunction · 0.85
ql_syscall_bindFunction · 0.85
ql_syscall_getsocknameFunction · 0.85
ql_syscall_getpeernameFunction · 0.85
ql_syscall_listenFunction · 0.85
ql_syscall_acceptFunction · 0.85
ql_syscall_recvFunction · 0.85
ql_syscall_sendFunction · 0.85
ql_syscall_recvmsgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected