diff --git a/gtests/net/packetdrill/script.c b/gtests/net/packetdrill/script.c index ee105cb9cddaeb02395c595d42aafb808f357319..b77b94040579677bae004c8af6cfbf94c4793117 100644 --- a/gtests/net/packetdrill/script.c +++ b/gtests/net/packetdrill/script.c @@ -106,6 +106,8 @@ struct expression_type_entry expression_type_table[] = { { EXPR_SCTP_ASSOC_IDS, "sctp_assoc_ids" }, { EXPR_SCTP_AUTHCHUNKS, "sctp_authchunks" }, { EXPR_SCTP_SETPEERPRIM, "sctp_setpeerprim"}, + { EXPR_SCTP_AUTHCHUNK, "sctp_authchunk" }, + { EXPR_SCTP_AUTHKEY, "sctp_authkey" }, { NUM_EXPR_TYPES, NULL} }; @@ -596,6 +598,15 @@ void free_expression(struct expression *expression) free_expression(expression->value.sctp_setpeerprim->sspp_assoc_id); free_expression(expression->value.sctp_setpeerprim->sspp_addr); break; + case EXPR_SCTP_AUTHCHUNK: + free_expression(expression->value.sctp_authchunk->sauth_chunk); + break; + case EXPR_SCTP_AUTHKEY: + free_expression(expression->value.sctp_authkey->sca_assoc_id); + free_expression(expression->value.sctp_authkey->sca_keynumber); + free_expression(expression->value.sctp_authkey->sca_keylength); + free_expression(expression->value.sctp_authkey->sca_key); + break; case EXPR_WORD: assert(expression->value.string); free(expression->value.string); @@ -2348,6 +2359,65 @@ static int evaluate_sctp_setpeerprim_expression(struct expression *in, return STATUS_OK; } +static int evaluate_sctp_authchunk_expression(struct expression *in, + struct expression *out, + char **error) +{ + struct sctp_authchunk_expr *in_authchunk; + struct sctp_authchunk_expr *out_authchunk; + + assert(in->type == EXPR_SCTP_AUTHCHUNK); + assert(in->value.sctp_authchunk); + assert(out->type == EXPR_SCTP_AUTHCHUNK); + + out->value.sctp_authchunk = calloc(1, sizeof(struct sctp_authchunk_expr)); + + in_authchunk = in->value.sctp_authchunk; + out_authchunk = out->value.sctp_authchunk; + + if (evaluate(in_authchunk->sauth_chunk, + &out_authchunk->sauth_chunk, + error)) + return STATUS_ERR; + return STATUS_OK; +} + +static int evaluate_sctp_authkey_expression(struct expression *in, + struct expression *out, + char **error) +{ + struct sctp_authkey_expr *in_authkey; + struct sctp_authkey_expr *out_authkey; + + assert(in->type == EXPR_SCTP_AUTHKEY); + assert(in->value.sctp_authkey); + assert(out->type == EXPR_SCTP_AUTHKEY); + + out->value.sctp_setpeerprim = calloc(1, sizeof(struct sctp_setpeerprim_expr)); + + in_authkey = in->value.sctp_authkey; + out_authkey = out->value.sctp_authkey; + + if (evaluate(in_authkey->sca_assoc_id, + &out_authkey->sca_assoc_id, + error)) + return STATUS_ERR; + if (evaluate(in_authkey->sca_keynumber, + &out_authkey->sca_keynumber, + error)) + return STATUS_ERR; + if (evaluate(in_authkey->sca_keylength, + &out_authkey->sca_keylength, + error)) + return STATUS_ERR; + if (evaluate(in_authkey->sca_key, + &out_authkey->sca_key, + error)) + return STATUS_ERR; + + return STATUS_OK; +} + static int evaluate(struct expression *in, struct expression **out_ptr, char **error) { @@ -2490,6 +2560,12 @@ static int evaluate(struct expression *in, case EXPR_SCTP_SETPEERPRIM: result = evaluate_sctp_setpeerprim_expression(in, out, error); break; + case EXPR_SCTP_AUTHCHUNK: + result = evaluate_sctp_authchunk_expression(in, out, error); + break; + case EXPR_SCTP_AUTHKEY: + result = evaluate_sctp_authkey_expression(in, out, error); + break; case EXPR_WORD: out->type = EXPR_INTEGER; if (symbol_to_int(in->value.string, diff --git a/gtests/net/packetdrill/script.h b/gtests/net/packetdrill/script.h index 36a70bfd064a53f2ae62f7e350aa4e614390ef62..6769d095c235523409f84915806502704ee57d23 100644 --- a/gtests/net/packetdrill/script.h +++ b/gtests/net/packetdrill/script.h @@ -86,6 +86,8 @@ enum expression_t { EXPR_SCTP_ASSOC_IDS, /* expression tree for sctp_assoc_ids struct for [gs]etsockopt */ EXPR_SCTP_AUTHCHUNKS, /* expression tree for sctp_authchunks struct for [gs]etsockopt */ EXPR_SCTP_SETPEERPRIM, /* expression tree for sctp_setpeerprim struct for [gs]etsockopt */ + EXPR_SCTP_AUTHCHUNK, /* expression tree for sctp_authchunk struct for setsockopt */ + EXPR_SCTP_AUTHKEY, /* expression tree for sctp_authkey struct for setsockopt */ NUM_EXPR_TYPES, }; /* Convert an expression type to a human-readable string */ @@ -145,6 +147,8 @@ struct expression { struct sctp_assoc_ids_expr *sctp_assoc_ids; struct sctp_authchunks_expr *sctp_authchunks; struct sctp_setpeerprim_expr *sctp_setpeerprim; + struct sctp_authchunk_expr *sctp_authchunk; + struct sctp_authkey_expr *sctp_authkey; } value; const char *format; /* the printf format for printing the value */ }; @@ -548,6 +552,19 @@ struct sctp_setpeerprim_expr { struct expression *sspp_addr; }; +/* Parse tree for sctp_authchunk struct for setsockopt. */ +struct sctp_authchunk_expr { + struct expression *sauth_chunk; +}; + +/* Parse tree for sctp_authkey struct for setsockopt. */ +struct sctp_authkey_expr { + struct expression *sca_assoc_id; + struct expression *sca_keynumber; + struct expression *sca_keylength; + struct expression *sca_key; +}; + /* The errno-related info from strace to summarize a system call error */ struct errno_spec { const char *errno_macro; /* errno symbol (C macro name) */