static int sctp_init_ack_chunk_to_string(FILE *s,
					 struct sctp_init_ack_chunk *chunk,
					 char **error)
{
	struct sctp_parameters_iterator iter;
	struct sctp_parameter *parameter;
	u16 length, parameters_length;
	u8 flags;
	int result = STATUS_OK;

	assert(*error == NULL);
	flags = chunk->flags;
	length = ntohs(chunk->length);
	if (length < sizeof(struct sctp_init_ack_chunk)) {
		asprintf(error, "INIT_ACK chunk too short (length=%u)", length);
		return STATUS_ERR;
	}
	parameters_length = length - sizeof(struct sctp_init_ack_chunk);
	fputs("INIT_ACK[", s);
	fprintf(s, "flgs=0x%02x, ", chunk->flags);
	fprintf(s, "tag=%u, ", ntohl(chunk->initiate_tag));
	fprintf(s, "a_rwnd=%d, ", ntohl(chunk->a_rwnd));
	fprintf(s, "os=%u, ", ntohs(chunk->os));
	fprintf(s, "is=%u, ", ntohs(chunk->is));
	fprintf(s, "tsn=%u", ntohl(chunk->initial_tsn));
	for (parameter = sctp_parameters_begin(chunk->parameter,
					       parameters_length,
					       &iter, error);
	     parameter != NULL;
	     parameter = sctp_parameters_next(&iter, error)) {
		fputs(", ", s);
		if (*error != NULL)
			break;
		result = sctp_parameter_to_string(s, parameter, error);
		if (result != STATUS_OK)
			break;
	}
	fputc(']', s);
	if (*error != NULL)
		result = STATUS_ERR;
	return result;
}
static int sctp_restart_with_new_addresses_cause_to_string(
	FILE *s,
	struct sctp_restart_with_new_addresses_cause *cause,
	char **error)
{
	u16 length, addressess_length, index;
	struct sctp_parameters_iterator iter;
	struct sctp_parameter *parameter;
	int result = STATUS_OK;

	length = ntohs(cause->length);
	if (length < sizeof(struct sctp_restart_with_new_addresses_cause)) {
		asprintf(error,
			 "RESTART_WITH_NEW_ADDRESSES cause too short (length=%u)",
			 length);
		return STATUS_ERR;
	}
	addressess_length =
		length - sizeof(struct sctp_restart_with_new_addresses_cause);
	fputs("RESTART_WITH_NEW_ADDRESSES[", s);
	index = 0;
	for (parameter = sctp_parameters_begin(cause->addresses,
					       addressess_length,
					       &iter, error);
	     parameter != NULL;
	     parameter = sctp_parameters_next(&iter, error)) {
		if (index > 0)
			fputs(", ", s);
		if (*error != NULL)
			break;
		result = sctp_parameter_to_string(s, parameter, error);
		if (result != STATUS_OK)
			break;
		index++;
	}
	fputc(']', s);
	return STATUS_OK;
}
static int sctp_unrecognized_parameters_cause_to_string(
	FILE *s,
	struct sctp_unrecognized_parameters_cause *cause,
	char **error)
{
	u16 length, parameters_length, index;
	struct sctp_parameters_iterator iter;
	struct sctp_parameter *parameter;
	int result = STATUS_OK;

	length = ntohs(cause->length);
	if (length < sizeof(struct sctp_unrecognized_parameters_cause)) {
		asprintf(error,
			 "UNRECOGNIZED_PARAMETERS cause too short (length=%u)",
			 length);
		return STATUS_ERR;
	}
	parameters_length = length -
			    sizeof(struct sctp_unrecognized_parameters_cause);
	fputs("UNRECOGNIZED_PARAMETERS[", s);
	index = 0;
	for (parameter = sctp_parameters_begin(cause->parameters,
					       parameters_length,
					       &iter, error);
	     parameter != NULL;
	     parameter = sctp_parameters_next(&iter, error)) {
		if (index > 0)
			fputs(", ", s);
		if (*error != NULL)
			break;
		result = sctp_parameter_to_string(s, parameter, error);
		if (result != STATUS_OK)
			break;
		index++;
	}
	fputc(']', s);
	return STATUS_OK;
}