示例#1
0
_PUBLIC_ int swrap_socket(int family, int type, int protocol)
{
	struct socket_info *si;
	int fd;

	if (!socket_wrapper_dir()) {
		return real_socket(family, type, protocol);
	}

	switch (family) {
	case AF_INET:
#ifdef HAVE_IPV6
	case AF_INET6:
#endif
		break;
	case AF_UNIX:
		return real_socket(family, type, protocol);
	default:
		errno = EAFNOSUPPORT;
		return -1;
	}

	switch (type) {
	case SOCK_STREAM:
		break;
	case SOCK_DGRAM:
		break;
	default:
		errno = EPROTONOSUPPORT;
		return -1;
	}

#if 0
	switch (protocol) {
	case 0:
		break;
	default:
		errno = EPROTONOSUPPORT;
		return -1;
	}
#endif

	fd = real_socket(AF_UNIX, type, 0);

	if (fd == -1) return -1;

	si = (struct socket_info *)calloc(1, sizeof(struct socket_info));

	si->family = family;
	si->type = type;
	si->protocol = protocol;
	si->fd = fd;

	SWRAP_DLIST_ADD(sockets, si);

	return si->fd;
}
示例#2
0
int socket(int family, int type, int protocol)
{
	static int (*real_socket)(int, int, int) = NULL;
	int fd = -1;
	struct fsocket_ioctl_arg arg;

	if (fsocket_channel_fd >= 0) {
		arg.op.socket_op.family = family;
		arg.op.socket_op.type = type;
		arg.op.socket_op.protocol = protocol;

		fd = ioctl(fsocket_channel_fd, FSOCKET_IOC_SOCKET, &arg);
		if (fd < 0)
			FSOCKET_ERR("FSOCKET:create light socket failed!\n");
		else
			fd = fastsocket_expand_fdset(fd);
	} else {
		if (!real_socket)
			real_socket = dlsym(RTLD_NEXT, "socket");

		fd =  real_socket(family, type, protocol);
	}

	return fd;
}
示例#3
0
文件: network.c 项目: Mario1224/poser
//TODO: make these actually print out the AF_UNIX etc etc
int socket(int domain, int type, int protocol) {
	static int (*real_socket)(int, int, int) = NULL;
	int ret;
	if (!real_socket) real_socket = dlsym(RTLD_NEXT, "socket");

	ret = real_socket(domain, type, protocol);
	printf("%d = socket(%d, %d, %d)\n", ret ,domain, type, protocol);
	return(ret);
}
示例#4
0
__attribute__ ((visibility("default"))) int
socket(int domain, int type, int protocol)
{
	wrapped_calls_socket++;

	if (fall_back && (type & SOCK_CLOEXEC)) {
		errno = EINVAL;
		return -1;
	}

	return real_socket(domain, type, protocol);
}
int
socket(int domain, int type, int protocol) throw()
{
  int retval;

  print_trace ("%*ssocket(%d, %d, %d)=...\n", indent, "",
	       domain, type, protocol);
  indent+=2;

  /* call the real socket function */
  retval = real_socket (domain, type, protocol);

  indent-=2;
  print_trace ("%*ssocket(%d, %d, %d)=%d\n", indent, "", 
	       domain, type, protocol, retval);

  return retval;
}
示例#6
0
/**
 * @param 
 *
 * @return  
 *
 */
int socket(int domain, int type, int protocol)
{
    int rc;

     ODP_FD_DEBUG("socket create start , domain %d, type %d \n", domain, type);    
   
    if ((inited == 0) ||  (AF_INET != domain) || (SOCK_STREAM != type && SOCK_DGRAM != type))
    {
        rc = real_socket(domain, type, protocol);
        ODP_FD_DEBUG("linux socket fd %d \n", rc);    

        return rc;
    }

    assert(inited);
    rc = netdpsock_socket(domain, type, protocol);
    
    if(rc > 0)
        rc += ODP_FD_BASE;
    
    ODP_FD_DEBUG("netdp socket fd %d \n", rc);    
    return rc;
}