def getsockopt(self, emu, argv, ctx={}): """ int getsockopt( SOCKET s, int level, int optname, char *optval, int *optlen ); """ s, level, optname, optval, optlen = argv rv = 0 opt_level = winsock.get_define(level, 'SOL_') if opt_level: argv[1] = opt_level opt_len = self.mem_read(optlen, 4) opt_len = struct.unpack('<I', opt_len)[0] argv[4] = opt_len opt_name = winsock.get_define(optname, 'SO_') if opt_name: argv[2] = opt_name if opt_name == 'SO_RCVBUF' or opt_name == 'SO_SNDBUF': opt_val = winsock.SOCK_BUF_SIZE self.mem_write(optval, opt_val.to_bytes(opt_len, 'little')) return rv
def setsockopt(self, emu, argv, ctx={}): """ int setsockopt( SOCKET s, int level, int optname, const char *optval, int optlen ); """ s, level, optname, optval, optlen = argv rv = 0 opt_level = winsock.get_define(level, 'SOL_') if opt_level: argv[1] = opt_level opt_name = winsock.get_define(optname, 'SO_') if opt_name: argv[2] = opt_name if opt_name == 'SO_RCVBUF' or opt_name == 'SO_SNDBUF': opt_val = self.mem_read(optval, optlen) argv[3] = struct.unpack('<I', opt_val)[0] return rv