From 6442001d9aaa4ec90584fbe2f17c073c6feb1969 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Tue, 24 Apr 2018 23:06:07 +0200 Subject: [PATCH] Add SCTP support for MacOS, if kext is available. --- gtests/net/packetdrill/platforms.h | 4 + gtests/net/packetdrill/run_system_call.c | 118 ++++++------- gtests/net/packetdrill/symbols_darwin.c | 211 +++++++++++++++++++++++ 3 files changed, 275 insertions(+), 58 deletions(-) diff --git a/gtests/net/packetdrill/platforms.h b/gtests/net/packetdrill/platforms.h index 17935f47..e277272b 100644 --- a/gtests/net/packetdrill/platforms.h +++ b/gtests/net/packetdrill/platforms.h @@ -106,6 +106,10 @@ #if defined(__APPLE__) +#if defined(HAVE_SCTP) +#include <sys/types.h> +#include <netinet/sctp.h> +#endif #define USE_LIBPCAP 1 #define HAVE_TCP_INFO 1 #define HAVE_FMEMOPEN 1 diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index 91fb6558..68cc766c 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -76,7 +76,7 @@ struct sctp_tlv { u32 sn_length; }; #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_notification(struct socket *socket, struct iovec *iov, struct expression *iovec_expr, char **error); static int parse_expression_to_sctp_initmsg(struct expression *expr, struct sctp_initmsg *init, @@ -84,7 +84,7 @@ static int parse_expression_to_sctp_initmsg(struct expression *expr, struct sctp static int parse_expression_to_sctp_sndrcvinfo(struct expression *expr, struct sctp_sndrcvinfo *info, bool send, char **error); #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int parse_expression_to_sctp_sndinfo(struct expression *expr, struct sctp_sndinfo *info, char **error); static int parse_expression_to_sctp_prinfo(struct expression *expr, struct sctp_prinfo *info, @@ -100,19 +100,19 @@ static int check_sctp_sndinfo(struct sctp_sndinfo_expr *expr, struct sctp_sndinf static int check_sctp_initmsg(struct sctp_initmsg_expr *expr, struct sctp_initmsg *sctp_initmsg, char **error); #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_extrcvinfo(struct sctp_extrcvinfo_expr *expr, struct sctp_extrcvinfo *sctp_info, char **error); #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_rcvinfo(struct sctp_rcvinfo_expr *expr, struct sctp_rcvinfo *sctp_rcvinfo, char** error); #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_nxtinfo(struct sctp_nxtinfo_expr *expr, struct sctp_nxtinfo *sctp_nxtinfo, char **error); #endif -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_sndrcvinfo(struct sctp_sndrcvinfo_expr *expr, struct sctp_sndrcvinfo *sctp_sndrcvinfo, char** error); @@ -351,7 +351,7 @@ static int get_socklen_t(struct expression *expression, return STATUS_OK; } -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) /* Sets the value from the expression argument, checking that it is a * valid size_t, and matches the expected type. Returns STATUS_OK on * success; on failure returns STATUS_ERR and sets error message. @@ -393,7 +393,7 @@ static int get_off_t(struct expression *expression, } #endif -#if defined(linux) || defined(__FreeBSD__) +#if defined(linux) || defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) /* Sets the value from the expression argument, checking that it is a * valid sctp_assoc_t, and matches the expected type. Returns STATUS_OK on * success; on failure returns STATUS_ERR and sets error message. @@ -584,7 +584,7 @@ static int s32_bracketed_arg(struct expression_list *args, /* Return the value of the argument with the given index, and verify * that it has the expected type: a list with a single integer. */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int u32_bracketed_arg(struct expression_list *args, int index, u32 *value, char **error) { @@ -604,7 +604,9 @@ static int u32_bracketed_arg(struct expression_list *args, } return get_u32(list->expression, value, error); } +#endif +#if defined(__FreeBSD__) static int off_t_bracketed_arg(struct expression_list *args, int index, off_t *value, char **error) { @@ -683,7 +685,7 @@ static int get_sockstorage_arg(struct expression *arg, struct sockaddr_storage * } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sockaddr(struct expression *sockaddr_expr, struct sockaddr *live_addr, char **error) { if (sockaddr_expr->type != EXPR_ELLIPSIS) { @@ -748,7 +750,7 @@ static int check_sockaddr(struct expression *sockaddr_expr, struct sockaddr *liv } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int check_u8_expr(struct expression *expr, u8 value, char *val_name, char **error) { if (expr->type != EXPR_ELLIPSIS) { u8 script_val; @@ -765,7 +767,7 @@ int check_u8_expr(struct expression *expr, u8 value, char *val_name, char **erro } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) #ifdef SCTP_REMOTE_UDP_ENCAPS_PORT int check_u16_htons_expr(struct expression *expr, u16 value, char *val_name, char **error) { if (expr->type != EXPR_ELLIPSIS) { @@ -846,7 +848,7 @@ int check_u32_expr(struct expression *expr, u32 value, char *val_name, char **er return STATUS_OK; } -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int check_sctp_assoc_t_expr(struct expression *expr, sctp_assoc_t value, char *val_name, char **error) { if (expr->type != EXPR_ELLIPSIS) { sctp_assoc_t script_val; @@ -895,7 +897,7 @@ int check_size_t_expr(struct expression *expr, size_t value, char *val_name, cha } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_u8array_expr(struct expression *expr_list, u8 *data, size_t data_len, char *val_name, char **error) { if ( expr_list->type != EXPR_ELLIPSIS) { struct expression *expr = NULL; @@ -937,7 +939,7 @@ static int check_u8array_expr(struct expression *expr_list, u8 *data, size_t dat } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_u16array_expr(struct expression *expr_list, u16 *data, int data_len, char *val_name, char **error) { if ( expr_list->type != EXPR_ELLIPSIS) { struct expression *expr = NULL; @@ -2051,7 +2053,7 @@ static int run_syscall_connect(struct state *state, return STATUS_OK; } -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int run_syscall_sctp_peeloff(struct state *state, int script_copy_fd, int script_new_fd, @@ -2445,7 +2447,7 @@ static int syscall_recvmsg(struct state *state, struct syscall_spec *syscall, expected_msg_flags, msg->msg_flags); goto error_out; } -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) if (msg->msg_flags & MSG_NOTIFICATION) { struct socket *socket = find_socket_by_script_fd(state, script_fd); if (check_sctp_notification(socket, msg->msg_iov, msg_expression->value.msghdr->msg_iov, error)) @@ -4475,7 +4477,7 @@ static int syscall_setsockopt(struct state *state, struct syscall_spec *syscall, &paddrparams.spp_flags, error)) { return STATUS_ERR; } -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) if (get_u32(val_expression->value.sctp_paddrparams->spp_ipv6_flowlabel, &paddrparams.spp_ipv6_flowlabel, error)) { return STATUS_ERR; @@ -4932,7 +4934,7 @@ error_out: static int syscall_sctp_sendmsg(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int result, script_fd, live_fd; void *msg = NULL; struct sockaddr_storage to; @@ -5015,7 +5017,7 @@ static int syscall_sctp_sendmsg(struct state *state, struct syscall_spec *syscal #endif } -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_sndrcvinfo(struct sctp_sndrcvinfo_expr *expr, struct sctp_sndrcvinfo *sctp_sndrcvinfo, char** error) { @@ -5051,7 +5053,7 @@ static int check_sctp_sndrcvinfo(struct sctp_sndrcvinfo_expr *expr, } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_extrcvinfo(struct sctp_extrcvinfo_expr *expr, struct sctp_extrcvinfo *sctp_extrcvinfo, char** error) { @@ -5130,7 +5132,7 @@ static int syscall_sctp_recvmsg(struct state *state, struct syscall_spec *syscal struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int script_fd, live_fd, live_msg_flags = 0, result; void *msg; u32 len; @@ -5193,7 +5195,7 @@ static int syscall_sctp_recvmsg(struct state *state, struct syscall_spec *syscal #endif } -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int parse_expression_to_sctp_initmsg(struct expression *expr, struct sctp_initmsg *init, char **error) { if (expr->type == EXPR_SCTP_INITMSG) { struct sctp_initmsg_expr *init_expr = expr->value.sctp_initmsg; @@ -5322,7 +5324,7 @@ static int parse_expression_to_sctp_sndrcvinfo(struct expression *expr, } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int parse_expression_to_sctp_sndinfo(struct expression *expr, struct sctp_sndinfo *info, char **error) { if (expr->type == EXPR_SCTP_SNDINFO) { struct sctp_sndinfo_expr *sndinfo_expr = expr->value.sctp_sndinfo; @@ -5402,7 +5404,7 @@ static int parse_expression_to_sctp_sendv_spa(struct expression *expr, struct sc } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int get_sockaddr_from_list(struct expression *expr, size_t *addr_size, struct sockaddr **addrs, char **error) { if (expr->type == EXPR_LIST) { struct expression_list *addrs_expr_list = (struct expression_list *)expr->value.list; @@ -5455,7 +5457,7 @@ static int syscall_sctp_send(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int script_fd, live_fd, flags, result; size_t len; void *msg; @@ -5510,7 +5512,7 @@ static int syscall_sctp_sendx(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) int script_fd, live_fd, flags, addrcnt, result; size_t len; void *msg = NULL; @@ -5593,7 +5595,7 @@ static int syscall_sctp_sendv(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) int script_fd, live_fd, iovcnt, addrcnt, result, flags; u32 infotype; size_t script_iovec_list_len = 0; @@ -5713,7 +5715,7 @@ error_out: #endif } -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_rcvinfo(struct sctp_rcvinfo_expr *expr, struct sctp_rcvinfo *sctp_rcvinfo, char **error) @@ -5743,7 +5745,7 @@ static int check_sctp_rcvinfo(struct sctp_rcvinfo_expr *expr, } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_nxtinfo(struct sctp_nxtinfo_expr *expr, struct sctp_nxtinfo *sctp_nxtinfo, char **error) @@ -5768,7 +5770,7 @@ static int check_sctp_nxtinfo(struct sctp_nxtinfo_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_assoc_change(struct sctp_assoc_change_expr *expr, struct sctp_assoc_change *sctp_event, char **error) { @@ -5804,7 +5806,7 @@ static int check_sctp_assoc_change(struct sctp_assoc_change_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_paddr_change(struct sctp_paddr_change_expr *expr, struct sctp_paddr_change *sctp_event, char **error) { @@ -5834,7 +5836,7 @@ static int check_sctp_paddr_change(struct sctp_paddr_change_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_remote_error(struct sctp_remote_error_expr *expr, struct sctp_remote_error *sctp_event, char **error) { @@ -5861,7 +5863,7 @@ static int check_sctp_remote_error(struct sctp_remote_error_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_send_failed(struct sctp_send_failed_expr *expr, struct sctp_send_failed *sctp_event, char **error) { @@ -5894,7 +5896,7 @@ static int check_sctp_send_failed(struct sctp_send_failed_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_shutdown_event(struct sctp_shutdown_event_expr *expr, struct sctp_shutdown_event *sctp_event, char **error) { @@ -5916,7 +5918,7 @@ static int check_sctp_shutdown_event(struct sctp_shutdown_event_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_adaptation_event(struct sctp_adaptation_event_expr *expr, struct sctp_adaptation_event *sctp_event, char **error) { @@ -5941,7 +5943,7 @@ static int check_sctp_adaptation_event(struct sctp_adaptation_event_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_pdapi_event(struct sctp_pdapi_event_expr *expr, struct sctp_pdapi_event *sctp_event, char **error) { @@ -5986,7 +5988,7 @@ static int check_sctp_pdapi_event(struct sctp_pdapi_event_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_authkey_event(struct sctp_authkey_event_expr *expr, struct sctp_authkey_event *sctp_event, char **error) { @@ -6014,7 +6016,7 @@ static int check_sctp_authkey_event(struct sctp_authkey_event_expr *expr, } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_sender_dry_event(struct sctp_sender_dry_event_expr *expr, struct sctp_sender_dry_event *sctp_event, char **error) { @@ -6036,7 +6038,7 @@ static int check_sctp_sender_dry_event(struct sctp_sender_dry_event_expr *expr, } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_send_failed_event(struct sctp_send_failed_event_expr *expr, struct sctp_send_failed_event *sctp_event, char **error) { @@ -6068,7 +6070,7 @@ static int check_sctp_send_failed_event(struct sctp_send_failed_event_expr *expr } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_tlv(struct sctp_tlv_expr *expr, struct sctp_tlv *sctp_tlv, char **error) { if (check_u16_expr(expr->sn_type, sctp_tlv->sn_type, "sctp_tlv.sn_type", error)) @@ -6083,7 +6085,7 @@ static int check_sctp_tlv(struct sctp_tlv_expr *expr, struct sctp_tlv *sctp_tlv, } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_stream_reset_event(struct sctp_stream_reset_event_expr *expr, struct sctp_stream_reset_event *sctp_stream_reset_event, char **error) { @@ -6108,7 +6110,7 @@ static int check_sctp_stream_reset_event(struct sctp_stream_reset_event_expr *ex } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_assoc_reset_event(struct socket *socket, struct sctp_assoc_reset_event_expr *expr, struct sctp_assoc_reset_event *sctp_assoc_reset_event, char **error) { @@ -6142,7 +6144,7 @@ static int check_sctp_assoc_reset_event(struct socket *socket, struct sctp_assoc } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_stream_change_event(struct sctp_stream_change_event_expr *expr, struct sctp_stream_change_event *sctp_stream_change_event, char **error) { @@ -6169,7 +6171,7 @@ static int check_sctp_stream_change_event(struct sctp_stream_change_event_expr * } #endif -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_notification(struct socket *socket, struct iovec *iov, struct expression *iovec_expr, @@ -6242,7 +6244,7 @@ static int check_sctp_notification(struct socket *socket, error)) return STATUS_ERR; break; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) case EXPR_SCTP_SEND_FAILED_EVENT: if (check_sctp_send_failed_event(script_iov_base->value.sctp_send_failed_event, (struct sctp_send_failed_event *) iov[i].iov_base, @@ -6256,7 +6258,7 @@ static int check_sctp_notification(struct socket *socket, error)) return STATUS_ERR; break; -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) case EXPR_SCTP_STREAM_RESET_EVENT: if (check_sctp_stream_reset_event(script_iov_base->value.sctp_stream_reset_event, (struct sctp_stream_reset_event *) iov[i].iov_base, @@ -6264,7 +6266,7 @@ static int check_sctp_notification(struct socket *socket, return STATUS_ERR; break; #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) case EXPR_SCTP_ASSOC_RESET_EVENT: if (check_sctp_assoc_reset_event(socket, script_iov_base->value.sctp_assoc_reset_event, (struct sctp_assoc_reset_event *) iov[i].iov_base, @@ -6272,7 +6274,7 @@ static int check_sctp_notification(struct socket *socket, return STATUS_ERR; break; #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) case EXPR_SCTP_STREAM_CHANGE_EVENT: if (check_sctp_stream_change_event(script_iov_base->value.sctp_stream_change_event, (struct sctp_stream_change_event *) iov[i].iov_base, @@ -6295,7 +6297,7 @@ static int check_sctp_notification(struct socket *socket, } #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) static int check_sctp_recvv_rn(struct sctp_recvv_rn_expr *expr, struct sctp_recvv_rn *sctp_recvv_rn, char **error) @@ -6322,7 +6324,7 @@ static int syscall_sctp_recvv(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || (defined(__APPLE__) && defined(HAVE_SCTP)) int flags, iovlen, script_fd, live_fd, result; size_t script_iovec_list_len = 0; unsigned int infotype = 0; @@ -6489,7 +6491,7 @@ static int syscall_sctp_bindx(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int live_fd, script_fd, addrcnt, flags, result; struct sockaddr_storage addrs; struct expression *addr_list; @@ -6534,7 +6536,7 @@ static int syscall_sctp_bindx(struct state *state, struct syscall_spec *syscall, static int syscall_sctp_connectx(struct state *state, struct syscall_spec *syscall, struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int live_fd, script_fd, addrcnt, result; struct sockaddr_storage live_addr; struct expression *addrs_expr, *assoc_expr; @@ -6588,7 +6590,7 @@ static int syscall_sctp_peeloff(struct state *state, struct syscall_spec *syscal struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int live_fd, script_fd, result, script_new_fd; sctp_assoc_t assoc_id; struct expression *expr_assoc; @@ -6628,7 +6630,7 @@ static int syscall_sctp_getpaddrs(struct state *state, struct syscall_spec *sysc struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int live_fd, script_fd, result; sctp_assoc_t assoc_id; struct expression *assoc_expr, *addrs_list_expr; @@ -6692,7 +6694,7 @@ static int syscall_sctp_freepaddrs(struct state *state, struct syscall_spec *sys struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) struct expression *addrs_expr; if (check_arg_count(args, 1, error)) return STATUS_ERR; @@ -6713,7 +6715,7 @@ static int syscall_sctp_getladdrs(struct state *state, struct syscall_spec *sysc struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) int live_fd, script_fd, result; sctp_assoc_t assoc_id; struct expression *assoc_expr, *addrs_list_expr; @@ -6777,7 +6779,7 @@ static int syscall_sctp_freeladdrs(struct state *state, struct syscall_spec *sys struct expression_list *args, char **error) { -#if defined(__FreeBSD__) || defined(linux) +#if defined(__FreeBSD__) || defined(linux) || (defined(__APPLE__) && defined(HAVE_SCTP)) struct expression *addrs_expr; if (check_arg_count(args, 1, error)) return STATUS_ERR; diff --git a/gtests/net/packetdrill/symbols_darwin.c b/gtests/net/packetdrill/symbols_darwin.c index f6895ca7..05cee229 100644 --- a/gtests/net/packetdrill/symbols_darwin.c +++ b/gtests/net/packetdrill/symbols_darwin.c @@ -141,6 +141,217 @@ struct int_symbol platform_symbols_table[] = { { IPV6_PREFER_TEMPADDR, "IPV6_PREFER_TEMPADDR" }, { IPV6_BOUND_IF, "IPV6_BOUND_IF" }, +#if defined(HAVE_SCTP) + /* /usr/include/netinet/sctp.h and /usr/include/netinet/sctp_uio.h */ + { SCTP_RTOINFO, "SCTP_RTOINFO" }, + { SCTP_ASSOCINFO, "SCTP_ASSOCINFO" }, + { SCTP_INITMSG, "SCTP_INITMSG" }, + { SCTP_INIT, "SCTP_INIT" }, + { SCTP_NODELAY, "SCTP_NODELAY" }, + { SCTP_AUTOCLOSE, "SCTP_AUTOCLOSE" }, + { SCTP_PRIMARY_ADDR, "SCTP_PRIMARY_ADDR" }, + { SCTP_ADAPTATION_LAYER, "SCTP_ADAPTATION_LAYER" }, + { SCTP_DISABLE_FRAGMENTS, "SCTP_DISABLE_FRAGMENTS" }, + { SCTP_DEFAULT_SEND_PARAM, "SCTP_DEFAULT_SEND_PARAM" }, + { SCTP_I_WANT_MAPPED_V4_ADDR, "SCTP_I_WANT_MAPPED_V4_ADDR" }, + { SCTP_MAXSEG, "SCTP_MAXSEG" }, + { SCTP_HMAC_IDENT, "SCTP_HMAC_IDENT" }, + { SCTP_AUTH_ACTIVE_KEY, "SCTP_AUTH_ACTIVE_KEY" }, + { SCTP_DELAYED_SACK, "SCTP_DELAYED_SACK" }, + { SCTP_PARTIAL_DELIVERY_POINT, "SCTP_PARTIAL_DELIVERY_POINT" }, + { SCTP_AUTO_ASCONF, "SCTP_AUTO_ASCONF" }, + { SCTP_MAX_BURST, "SCTP_MAX_BURST" }, + { SCTP_CONTEXT, "SCTP_CONTEXT" }, + { SCTP_PEER_ADDR_PARAMS, "SCTP_PEER_ADDR_PARAMS" }, + { SCTP_EVENT, "SCTP_EVENT" }, + { SCTP_EXPLICIT_EOR, "SCTP_EXPLICIT_EOR" }, + { SCTP_REUSE_PORT, "SCTP_REUSE_PORT" }, + { SCTP_EVENTS, "SCTP_EVENTS" }, + { SCTP_DEFAULT_SNDINFO, "SCTP_DEFAULT_SNDINFO" }, + { SCTP_DEFAULT_PRINFO, "SCTP_DEFAULT_PRINFO" }, + { SCTP_STATUS, "SCTP_STATUS" }, + { SCTP_GET_PEER_ADDR_INFO, "SCTP_GET_PEER_ADDR_INFO" }, + { SCTP_PEER_AUTH_CHUNKS, "SCTP_PEER_AUTH_CHUNKS" }, + { SCTP_LOCAL_AUTH_CHUNKS, "SCTP_LOCAL_AUTH_CHUNKS" }, + { SCTP_GET_ASSOC_NUMBER, "SCTP_GET_ASSOC_NUMBER" }, + { SCTP_GET_ASSOC_ID_LIST, "SCTP_GET_ASSOC_ID_LIST" }, + { SCTP_SET_PEER_PRIMARY_ADDR, "SCTP_SET_PEER_PRIMARY_ADDR" }, + { SCTP_AUTH_CHUNK, "SCTP_AUTH_CHUNK" }, + { SCTP_AUTH_KEY, "SCTP_AUTH_KEY" }, + { SCTP_AUTH_DEACTIVATE_KEY, "SCTP_AUTH_DEACTIVATE_KEY" }, + { SCTP_AUTH_DELETE_KEY, "SCTP_AUTH_DELETE_KEY" }, + { SCTP_FRAGMENT_INTERLEAVE, "SCTP_FRAGMENT_INTERLEAVE" }, + { SCTP_EXPLICIT_EOR, "SCTP_EXPLICIT_EOR" }, +#if defined(SCTP_INTERLEAVING_SUPPORTED) + { SCTP_INTERLEAVING_SUPPORTED, "SCTP_INTERLEAVING_SUPPORTED" }, +#endif + { SCTP_REMOTE_UDP_ENCAPS_PORT, "SCTP_REMOTE_UDP_ENCAPS_PORT" }, + { SCTP_CLOSED, "SCTP_CLOSED" }, + { SCTP_BOUND, "SCTP_BOUND" }, + { SCTP_LISTEN, "SCTP_LISTEN" }, + { SCTP_COOKIE_WAIT, "SCTP_COOKIE_WAIT" }, + { SCTP_COOKIE_ECHOED, "SCTP_COOKIE_ECHOED" }, + { SCTP_ESTABLISHED, "SCTP_ESTABLISHED" }, + { SCTP_SHUTDOWN_SENT, "SCTP_SHUTDOWN_SENT" }, + { SCTP_SHUTDOWN_RECEIVED, "SCTP_SHUTDOWN_RECEIVED" }, + { SCTP_SHUTDOWN_ACK_SENT, "SCTP_SHUTDOWN_ACK_SENT" }, + { SCTP_SHUTDOWN_PENDING, "SCTP_SHUTDOWN_PENDING" }, + /* The following constants are from + * https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-04 + * The old symbols currently being deployed are also provided. + */ + { SCTP_PLUGGABLE_SS, "SCTP_PLUGGABLE_SS" }, + { SCTP_SS_VALUE, "SCTP_SS_VALUE" }, + { SCTP_SS_DEFAULT, "SCTP_SS_DEFAULT" }, + { SCTP_SS_ROUND_ROBIN, "SCTP_SS_ROUND_ROBIN" }, + { SCTP_SS_ROUND_ROBIN_PACKET, "SCTP_SS_ROUND_ROBIN_PACKET" }, + { SCTP_SS_PRIORITY, "SCTP_SS_PRIORITY" }, + /* The following is a typo in FreeBSD's sctp.h */ + { SCTP_SS_FAIR_BANDWITH, "SCTP_SS_FAIR_BANDWITH" }, + { SCTP_SS_FIRST_COME, "SCTP_SS_FIRST_COME" }, +#if defined(SCTP_SS_FCFS) + { SCTP_SS_FCFS, "SCTP_SS_FCFS" }, +#endif +#if defined(SCTP_SS_RR) + { SCTP_SS_RR, "SCTP_SS_RR" }, +#endif +#if defined(SCTP_SS_RR_PKT) + { SCTP_SS_RR_PKT, "SCTP_SS_RR_PKT" }, +#endif +#if defined(SCTP_SS_PRIO) + { SCTP_SS_PRIO, "SCTP_SS_PRIO" }, +#endif +#if defined(SCTP_SS_FB) + { SCTP_SS_FB, "SCTP_SS_FB" }, +#endif +#if defined(SCTP_SS_WFQ) + { SCTP_SS_WFQ, "SCTP_SS_WFQ" }, +#endif +#if defined(SCTP_SS_RR_INTER) + { SCTP_SS_RR_INTER, "SCTP_SS_RR_INTER" }, +#endif +#if defined(SCTP_SS_RR_PKT_INTER) + { SCTP_SS_RR_PKT_INTER, "SCTP_SS_RR_PKT_INTER" }, +#endif +#if defined(SCTP_SS_PRIO_INTER) + { SCTP_SS_PRIO_INTER, "SCTP_SS_PRIO_INTER" }, +#endif +#if defined(SCTP_SS_FB_INTER) + { SCTP_SS_FB_INTER, "SCTP_SS_FB_INTER" }, +#endif +#if defined(SCTP_SS_WFQ_INTER) + { SCTP_SS_WFQ_INTER, "SCTP_SS_WFQ_INTER" }, +#endif + { SCTP_UNCONFIRMED, "SCTP_UNCONFIRMED" }, + { SCTP_ACTIVE, "SCTP_ACTIVE" }, + { SCTP_INACTIVE, "SCTP_INACTIVE" }, + { SPP_HB_ENABLE, "SPP_HB_ENABLE" }, + { SPP_HB_DISABLE, "SPP_HB_DISABLE" }, + { SPP_HB_DEMAND, "SPP_HB_DEMAND" }, + { SPP_HB_TIME_IS_ZERO, "SPP_HB_TIME_IS_ZERO" }, + { SPP_PMTUD_ENABLE, "SPP_PMTUD_ENABLE" }, + { SPP_PMTUD_DISABLE, "SPP_PMTUD_DISABLE" }, + { SPP_IPV6_FLOWLABEL, "SPP_IPV6_FLOWLABEL" }, + { SPP_DSCP, "SPP_DSCP" }, + { SCTP_ASSOC_CHANGE, "SCTP_ASSOC_CHANGE" }, + { SCTP_PEER_ADDR_CHANGE, "SCTP_PEER_ADDR_CHANGE" }, + { SCTP_REMOTE_ERROR, "SCTP_REMOTE_ERROR" }, + { SCTP_SEND_FAILED, "SCTP_SEND_FAILED" }, + { SCTP_SHUTDOWN_EVENT, "SCTP_SHUTDOWN_EVENT" }, + { SCTP_SENDER_DRY_EVENT, "SCTP_SENDER_DRY_EVENT" }, + { SCTP_SEND_FAILED_EVENT, "SCTP_SEND_FAILED_EVENT" }, + { SCTP_ADAPTATION_INDICATION, "SCTP_ADAPTATION_INDICATION" }, + { SCTP_ADAPTION_INDICATION, "SCTP_ADAPTION_INDICATION" }, + { SCTP_PARTIAL_DELIVERY_EVENT, "SCTP_PARTIAL_DELIVERY_EVENT" }, + { SCTP_AUTHENTICATION_EVENT, "SCTP_AUTHENTICATION_EVENT" }, + { SCTP_NOTIFICATIONS_STOPPED_EVENT, "SCTP_NOTIFICATIONS_STOPPED_EVENT"}, + { SCTP_SEND_FAILED_EVENT, "SCTP_SEND_FAILED_EVENT" }, + { SCTP_UNORDERED, "SCTP_UNORDERED" }, + { SCTP_COMPLETE, "SCTP_COMPLETE" }, + { SCTP_ADDR_OVER, "SCTP_ADDR_OVER" }, + { SCTP_ABORT, "SCTP_ABORT" }, + { SCTP_EOF, "SCTP_EOF" }, + { SCTP_SENDALL, "SCTP_SENDALL" }, + { SCTP_EOR, "SCTP_EOR" }, + { SCTP_NEXT_MSG_AVAIL, "SCTP_NEXT_MSG_AVAIL" }, + { SCTP_NEXT_MSG_ISCOMPLETE, "SCTP_NEXT_MSG_ISCOMPLETE" }, + { SCTP_NEXT_MSG_IS_UNORDERED, "SCTP_NEXT_MSG_IS_UNORDERED" }, + { SCTP_NEXT_MSG_IS_NOTIFICATION, "SCTP_NEXT_MSG_IS_NOTIFICATION" }, + { SCTP_SACK_IMMEDIATELY, "SCTP_SACK_IMMEDIATELY" }, + { SCTP_PR_SCTP_NONE, "SCTP_PR_SCTP_NONE" }, + { SCTP_PR_SCTP_TTL, "SCTP_PR_SCTP_TTL" }, + { SCTP_PR_SCTP_RTX, "SCTP_PR_SCTP_RTX" }, + { SCTP_PR_SCTP_PRIO, "SCTP_PR_SCTP_PRIO" }, + { SCTP_BINDX_ADD_ADDR, "SCTP_BINDX_ADD_ADDR" }, + { SCTP_BINDX_REM_ADDR, "SCTP_BINDX_REM_ADDR" }, + { SCTP_SENDV_NOINFO, "SCTP_SENDV_NOINFO" }, + { SCTP_SENDV_SNDINFO, "SCTP_SENDV_SNDINFO" }, + { SCTP_SENDV_PRINFO, "SCTP_SENDV_PRINFO" }, + { SCTP_SENDV_AUTHINFO, "SCTP_SENDV_AUTHINFO" }, + { SCTP_SENDV_SPA, "SCTP_SENDV_SPA" }, + { SCTP_SEND_SNDINFO_VALID, "SCTP_SEND_SNDINFO_VALID" }, + { SCTP_SEND_PRINFO_VALID, "SCTP_SEND_PRINFO_VALID" }, + { SCTP_SEND_AUTHINFO_VALID, "SCTP_SEND_AUTHINFO_VALID" }, + { SCTP_RECVV_NOINFO, "SCTP_RECVV_NOINFO" }, + { SCTP_RECVV_RCVINFO, "SCTP_RECVV_RCVINFO" }, + { SCTP_RECVV_NXTINFO, "SCTP_RECVV_NXTINFO" }, + { SCTP_RECVV_RN, "SCTP_RECVV_RN" }, + { SCTP_RECVRCVINFO, "SCTP_RECVRCVINFO" }, + { SCTP_RECVNXTINFO, "SCTP_RECVNXTINFO" }, + { SCTP_DATA_SENT, "SCTP_DATA_SENT" }, + { SCTP_DATA_UNSENT, "SCTP_DATA_UNSENT" }, + { SCTP_COMM_UP, "SCTP_COMM_UP" }, + { SCTP_COMM_LOST, "SCTP_COMM_LOST" }, + { SCTP_RESTART, "SCTP_RESTART" }, + { SCTP_SHUTDOWN_COMP, "SCTP_SHUTDOWN_COMP" }, + { SCTP_AUTH_NEW_KEY, "SCTP_AUTH_NEW_KEY" }, + { SCTP_AUTH_NO_AUTH, "SCTP_AUTH_NO_AUTH" }, + { SCTP_AUTH_FREE_KEY, "SCTP_AUTH_FREE_KEY" }, + { SCTP_ASSOC_SUPPORTS_PR, "SCTP_ASSOC_SUPPORTS_PR" }, + { SCTP_ASSOC_SUPPORTS_AUTH, "SCTP_ASSOC_SUPPORTS_AUTH" }, + { SCTP_ASSOC_SUPPORTS_ASCONF, "SCTP_ASSOC_SUPPORTS_ASCONF" }, + { SCTP_ASSOC_SUPPORTS_MULTIBUF, "SCTP_ASSOC_SUPPORTS_MULTIBUF" }, + { SCTP_PARTIAL_DELIVERY_ABORTED, "SCTP_PARTIAL_DELIVERY_ABORTED" }, + { SCTP_ADDR_AVAILABLE, "SCTP_ADDR_AVAILABLE" }, + { SCTP_ADDR_UNREACHABLE, "SCTP_ADDR_UNREACHABLE" }, + { SCTP_ADDR_REMOVED, "SCTP_ADDR_REMOVED" }, + { SCTP_ADDR_MADE_PRIM, "SCTP_ADDR_MADE_PRIM" }, + { SCTP_SNDRCV, "SCTP_SNDRCV" }, + { SCTP_SNDINFO, "SCTP_SNDINFO" }, + { SCTP_RCVINFO, "SCTP_RCVINFO" }, + { SCTP_NXTINFO, "SCTP_NXTINFO" }, + { SCTP_PRINFO, "SCTP_PRINFO" }, + { SCTP_AUTHINFO, "SCTP_AUTHINFO" }, + { SCTP_DSTADDRV4, "SCTP_DSTADDRV4" }, + { SCTP_DSTADDRV6, "SCTP_DSTADDRV6" }, + { SCTP_EXTRCV, "SCTP_EXTRCV" }, + { SCTP_USE_EXT_RCVINFO, "SCTP_USE_EXT_RCVINFO" }, + { SCTP_AUTH_HMAC_ID_SHA1, "SCTP_AUTH_HMAC_ID_SHA1" }, + { SCTP_AUTH_HMAC_ID_SHA256, "SCTP_AUTH_HMAC_ID_SHA256" }, + + /* sctp stream reconfiguration */ + { SCTP_ENABLE_STREAM_RESET, "SCTP_ENABLE_STREAM_RESET" }, + { SCTP_ENABLE_RESET_STREAM_REQ, "SCTP_ENABLE_RESET_STREAM_REQ" }, + { SCTP_ENABLE_RESET_ASSOC_REQ, "SCTP_ENABLE_RESET_ASSOC_REQ" }, + { SCTP_ENABLE_CHANGE_ASSOC_REQ, "SCTP_ENABLE_CHANGE_ASSOC_REQ" }, + { SCTP_RESET_STREAMS, "SCTP_RESET_STREAMS" }, + { SCTP_STREAM_RESET_INCOMING, "SCTP_STREAM_RESET_INCOMING" }, + { SCTP_STREAM_RESET_OUTGOING, "SCTP_STREAM_RESET_OUTGOING" }, + { SCTP_RESET_ASSOC, "SCTP_RESET_ASSOC" }, + { SCTP_ADD_STREAMS, "SCTP_ADD_STREAMS" }, + { SCTP_STREAM_RESET_EVENT, "SCTP_STREAM_RESET_EVENT" }, + { SCTP_STREAM_RESET_INCOMING_SSN, "SCTP_STREAM_RESET_INCOMING_SSN" }, + { SCTP_STREAM_RESET_OUTGOING_SSN, "SCTP_STREAM_RESET_OUTGOING_SSN" }, + { SCTP_STREAM_RESET_DENIED, "SCTP_STREAM_RESET_DENIED" }, + { SCTP_STREAM_RESET_FAILED, "SCTP_STREAM_RESET_FAILED" }, + { SCTP_ASSOC_RESET_EVENT, "SCTP_ASSOC_RESET_EVENT" }, + { SCTP_ASSOC_RESET_DENIED, "SCTP_ASSOC_RESET_DENIED" }, + { SCTP_ASSOC_RESET_FAILED, "SCTP_ASSOC_RESET_FAILED" }, + { SCTP_STREAM_CHANGE_EVENT, "SCTP_STREAM_CHANGE_EVENT" }, + { SCTP_STREAM_CHANGE_DENIED, "SCTP_STREAM_CHANGE_DENIED" }, + { SCTP_STREAM_CHANGE_FAILED, "SCTP_STREAM_CHANGE_FAILED" }, +#endif + /* /usr/include/netinet/tcp.h */ { TCP_NODELAY, "TCP_NODELAY" }, { TCP_MAXSEG, "TCP_MAXSEG" }, -- GitLab