コード例 #1
0
ファイル: interposer.c プロジェクト: dozylynx/v4v
INTERPOSE (socket, int, int domain, int type, int protocol)
{
  int ret;

  CHECK_INTERPOSE (socket);

  if ((domain != PF_XENV4V) && (domain != PF_INETV4V) &&
      ((domain != PF_INET) || (!getenv ("INET_IS_V4V"))) && !force_xen)
    return orig_socket (domain, type, protocol);

  ret = v4v_socket (type);
  if (ret < 0)
    return ret;

  register_fd (ret);

  if (domain == PF_XENV4V)
    register_af (ret);
  else
    unregister_af (ret);

  return ret;
}
コード例 #2
0
ファイル: socket.c プロジェクト: 2014-class/freerouter
/*..socket -- replacment socket call. */
int socket
(
 int domain,
 int type,
 int protocol
)
{
#ifdef i386
  long  __ret;
  void *__scratch;
  int   call[3];
#endif
  char *test;
  char *inet;
  char **tenviron;

#ifdef _SDP_VERBOSE_PRELOAD
  FILE *fd;
#endif
  /*
   * check for magic enviroment variable
   */
  if ((AF_INET == domain || AF_INET6 == domain) &&
      SOCK_STREAM == type) {

    if (environ) {
      tenviron = environ;
      for (test = *tenviron; NULL != test; test = *++tenviron) {

        inet = AF_INET_STR;

        while (*inet == *test && '\0' != *inet) {

          inet++;
	  test++;
        } /* while */

        if ('\0' == *inet && '=' == *test) {

          domain = AF_INET_SDP;
          break;
        } /* if */
      } /* for */
    } /* if */
  } /* if */

#ifdef _SDP_VERBOSE_PRELOAD
  fd = fopen("/tmp/libsdp.log.txt", "a+");

  fprintf(fd, "SOCKET: <%s> domain <%d> type <%d> protocol <%d>\n",
	  program_invocation_short_name, domain, type, protocol);

  fclose(fd);
#endif

#ifdef i386
  /* Make the socket() system call directly, as described above */
  call[0] = domain;
  call[1] = type;
  call[2] = protocol;

  __asm__ __volatile__("movl %%ebx, %1\n" /* save %ebx */
                       "movl %3, %%ebx\n" /* put sockopt in %ebx as arg */
                       "int $0x80\n"      /* do syscall */
                       "movl %1, %%ebx\n" /* restore %ebx */
                       : "=a" (__ret), "=r" (__scratch)
                       : "0" (__NR_socketcall),
		       "g" (SOCKOP_socket),
		       "c" (call));
  return __ret;
#else /* i386 */
  /* Use the standard library socket() to pass through the call */
  {
    static int (*orig_socket)(int, int, int);

    if (!orig_socket) {
      orig_socket = dlsym(RTLD_NEXT, "socket");
    }

    return orig_socket(domain, type, protocol);
  }
#endif /* i386 */
} /* socket */