2 * Copyright (C) 2017 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "swima_error.h"
18 #include <bio/bio_writer.h>
19 #include <ietf/ietf_attr_pa_tnc_error.h>
22 * SW_ERROR, SW_SUBSCRIPTION_DENIED_ERROR and SW_SUBSCRIPTION_ID_REUSE_ERROR
25 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
26 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 * | Copy of Request ID / Subscription ID |
28 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29 * | Description (variable length) |
30 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 * SW_RESPONSE_TOO_LARGE_ERROR
37 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
38 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * | Copy of Request ID / Subscription ID |
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * | Maximum Allowed Size |
42 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * | Description (variable length) |
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * Described in header.
50 pa_tnc_attr_t
* swima_error_create(pa_tnc_error_code_t code
, uint32_t request_id
,
51 uint32_t max_attr_size
, char *description
)
56 pen_type_t error_code
;
58 error_code
= pen_type_create( PEN_IETF
, code
);
59 writer
= bio_writer_create(4);
60 writer
->write_uint32(writer
, request_id
);
62 if (code
== PA_ERROR_SWIMA_RESPONSE_TOO_LARGE
)
64 writer
->write_uint32(writer
, max_attr_size
);
69 writer
->write_data(writer
, chunk_from_str(description
));
71 msg_info
= writer
->get_buf(writer
);
72 attr
= ietf_attr_pa_tnc_error_create(error_code
, msg_info
);
73 writer
->destroy(writer
);