int INTERPOSE(socket)(int domain, int type, int protocol) { __real_socket_init(); const bool bypass_filter = getenv("SIXJACK_BYPASS") != NULL; int ret = 0; int ret_errno = 0; bool bypass_call = false; FilterReplyResultBase rb = { .pre = true, .ret = &ret, .ret_errno = &ret_errno, .fd = -1 }; if (bypass_filter == false && (rb.filter = filter_get()) && filter_apply(&rb, &domain, &type, &protocol) == FILTER_REPLY_BYPASS) { bypass_call = true; } if (bypass_call == false) { ret = __real_socket(domain, type, protocol); ret_errno = errno; } if (bypass_filter == false) { rb.fd = ret; rb.pre = false; filter_apply(&rb, &domain, &type, &protocol); } errno = ret_errno; return ret; }
int __wrap_socket(int protocol_family, int socket_type, int protocol) { int ret; ret = XENOMAI_SKINCALL3(__pse51_rtdm_muxid, __rtdm_socket, protocol_family, socket_type, protocol); if (ret >= 0) ret += __pse51_rtdm_fd_start; else if (ret == -EAFNOSUPPORT || ret == -EPROTONOSUPPORT || ret == -ENOSYS) { ret = __real_socket(protocol_family, socket_type, protocol); if (ret >= __pse51_rtdm_fd_start) { __real_close(ret); errno = -EMFILE; ret = -1; } } else { errno = -ret; ret = -1; } return ret; }