Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 1 | #include <stdlib.h> |
| 2 | #include <stdio.h> |
| 3 | #include <unistd.h> |
| 4 | #include <assert.h> |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 5 | #include <string.h> |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 6 | |
| 7 | #include <osmocom/core/msgb.h> |
| 8 | #include <osmocom/core/utils.h> |
| 9 | |
| 10 | #include "ccid_proto.h" |
| 11 | |
| 12 | #define NR_SLOTS 8 |
| 13 | |
| 14 | struct ccid_slot { |
| 15 | struct ccid_instance *ci; |
| 16 | uint8_t slot_nr; |
| 17 | bool icc_present; |
| 18 | bool icc_powered; |
| 19 | bool icc_in_reset; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 20 | bool cmd_busy; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | struct ccid_ops { |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 24 | int (*send_in)(struct ccid_instance *ci, struct msgb *msg); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | struct ccid_instance { |
| 28 | struct ccid_slot slot[NR_SLOTS]; |
| 29 | struct ccid_ops ops; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 30 | const char *name; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | #define msgb_ccid_out(x) (union ccid_pc_to_rdr *)msgb_data(x) |
| 34 | #define msgb_ccid_in(x) (union ccid_rdr_to_pc *)msgb_data(x) |
| 35 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 36 | #define LOGPCI(ci, lvl, fmt, args ...) LOGP(DCCID, lvl, "%s: " fmt, (ci)->name, ## args) |
| 37 | #define LOGPCS(cs, lvl, fmt, args ...) \ |
| 38 | LOGP(DCCID, lvl, "%s(%u): " fmt, (cc)->ci->name, (cc)->slot_nr, ## args) |
| 39 | |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 40 | static struct ccid_slot *get_ccid_slot(struct ccid_instance *ci, uint8_t slot_nr) |
| 41 | { |
| 42 | if (slot_nr >= sizeof(ci->slot)) |
| 43 | return NULL; |
| 44 | else |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 45 | return &ci->slot[slot_nr]; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static uint8_t get_icc_status(const struct ccid_slot *cs) |
| 49 | { |
| 50 | if (cs->icc_present && cs->icc_powered && !cs->icc_in_reset) |
| 51 | return CCID_ICC_STATUS_PRES_ACT; |
| 52 | else if (!cs->icc_present) |
| 53 | return CCID_ICC_STATUS_NO_ICC; |
| 54 | else |
| 55 | return CCID_ICC_STATUS_PRES_INACT; |
| 56 | } |
| 57 | |
| 58 | #define SET_HDR(x, msg_type, slot, seq) do { \ |
| 59 | (x)->hdr.bMessageType = msg_type; \ |
| 60 | (x)->hdr.dwLength = 0; \ |
| 61 | (x)->hdr.bSlot = slot; \ |
| 62 | (x)->hdr.bSeq = seq; \ |
| 63 | } while (0) |
| 64 | |
| 65 | #define SET_HDR_IN(x, msg_type, slot, seq, status, error) do { \ |
| 66 | SET_HDR(&(x)->hdr, msg_type, slot, seq); \ |
| 67 | (x)->hdr.bStatus = status; \ |
| 68 | (x)->hdr.bError = error; \ |
| 69 | } while (0) |
| 70 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 71 | #if 0 |
| 72 | static uint8_t ccid_pc_to_rdr_get_seq(const struct ccid_pc_to_rdr *u) |
| 73 | { |
| 74 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 75 | return ch->bSeq; |
| 76 | } |
| 77 | #endif |
| 78 | |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 79 | /*********************************************************************** |
| 80 | * Message generation / sending |
| 81 | ***********************************************************************/ |
| 82 | |
| 83 | static struct msgb *ccid_msgb_alloc(void) |
| 84 | { |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 85 | struct msgb *msg = msgb_alloc(512, "ccid"); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 86 | OSMO_ASSERT(msg); |
| 87 | return msg; |
| 88 | } |
| 89 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 90 | /* Send given CCID message */ |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 91 | static int ccid_send(struct ccid_instance *ci, struct msgb *msg) |
| 92 | { |
| 93 | return ci->ops.send_in(ci, msg); |
| 94 | } |
| 95 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 96 | /* Send given CCID message for given slot; patch bSlot into message */ |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 97 | static int ccid_slot_send(struct ccid_slot *cs, struct msgb *msg) |
| 98 | { |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 99 | struct ccid_header *ch = (struct ccid_header *) msgb_ccid_in(msg); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 100 | |
| 101 | /* patch bSlotNr into message */ |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 102 | ch->bSlot = cs->slot_nr; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 103 | return ccid_send(cs->ci, msg); |
| 104 | } |
| 105 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 106 | /* Send given CCID message and mark slot as un-busy */ |
| 107 | static int ccid_slot_send_unbusy(struct ccid_slot *cs, struct msgb *msg) |
| 108 | { |
| 109 | cs->cmd_busy = false; |
| 110 | return ccid_slot_send(cs, msg); |
| 111 | } |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 112 | |
| 113 | /* Section 6.2.1 */ |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 114 | static struct msgb *ccid_gen_data_block_nr(uint8_t slot_nr, uint8_t icc_status, uint8_t seq, |
| 115 | uint8_t cmd_sts, enum ccid_error_code err, |
| 116 | const uint8_t *data, uint32_t data_len) |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 117 | { |
| 118 | struct msgb *msg = ccid_msgb_alloc(); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 119 | struct ccid_rdr_to_pc_data_block *db = |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 120 | (struct ccid_rdr_to_pc_data_block *) msgb_put(msg, sizeof(*db) + data_len); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 121 | uint8_t sts = (cmd_sts & CCID_CMD_STATUS_MASK) | icc_status; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 122 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 123 | SET_HDR_IN(db, RDR_to_PC_DataBlock, slot_nr, seq, sts, err); |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 124 | osmo_store32le(data_len, &db->hdr.hdr.dwLength); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 125 | memcpy(db->abData, data, data_len); |
| 126 | return msg; |
| 127 | } |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 128 | static struct msgb *ccid_gen_data_block(struct ccid_slot *cs, uint8_t seq, uint8_t cmd_sts, |
| 129 | enum ccid_error_code err, const uint8_t *data, |
| 130 | uint32_t data_len) |
| 131 | { |
| 132 | return ccid_gen_data_block_nr(cs->slot_nr, get_icc_status(cs), seq, cmd_sts, err, data, data_len); |
| 133 | } |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 134 | |
| 135 | /* Section 6.2.2 */ |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 136 | static struct msgb *ccid_gen_slot_status_nr(uint8_t slot_nr, uint8_t icc_status, |
| 137 | uint8_t seq, uint8_t cmd_sts, |
| 138 | enum ccid_error_code err) |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 139 | { |
| 140 | struct msgb *msg = ccid_msgb_alloc(); |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 141 | struct ccid_rdr_to_pc_slot_status *ss = |
| 142 | (struct ccid_rdr_to_pc_slot_status *) msgb_put(msg, sizeof(*ss)); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 143 | uint8_t sts = (cmd_sts & CCID_CMD_STATUS_MASK) | icc_status; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 144 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 145 | SET_HDR_IN(ss, RDR_to_PC_SlotStatus, slot_nr, seq, sts, err); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 146 | return msg; |
| 147 | } |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 148 | static struct msgb *ccid_gen_slot_status(struct ccid_slot *cs, uint8_t seq, uint8_t cmd_sts, |
| 149 | enum ccid_error_code err) |
| 150 | { |
| 151 | return ccid_gen_slot_status_nr(cs->slot_nr, get_icc_status(cs), seq, cmd_sts, err); |
| 152 | } |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 153 | |
| 154 | /* Section 6.2.3 */ |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 155 | static struct msgb *ccid_gen_parameters_t0_nr(uint8_t slot_nr, uint8_t icc_status, |
| 156 | uint8_t seq, uint8_t cmd_sts, enum ccid_error_code err, |
| 157 | const struct ccid_proto_data_t0 *t0) |
| 158 | { |
| 159 | struct msgb *msg = ccid_msgb_alloc(); |
| 160 | struct ccid_rdr_to_pc_parameters *par = |
| 161 | (struct ccid_rdr_to_pc_parameters *) msgb_put(msg, sizeof(par->hdr)+sizeof(*t0)); |
| 162 | uint8_t sts = (cmd_sts & CCID_CMD_STATUS_MASK) | icc_status; |
| 163 | |
| 164 | SET_HDR_IN(par, RDR_to_PC_Parameters, slot_nr, seq, sts, err); |
| 165 | if (t0) { |
| 166 | osmo_store32le(sizeof(*t0), &par->hdr.hdr.dwLength); |
| 167 | par->abProtocolData.t0 = *t0; |
| 168 | } |
| 169 | return msg; |
| 170 | } |
| 171 | static struct msgb *ccid_gen_parameters_t0(struct ccid_slot *cs, uint8_t seq, uint8_t cmd_sts, |
| 172 | enum ccid_error_code err, |
| 173 | const struct ccid_proto_data_t0 *t0) |
| 174 | { |
| 175 | return ccid_gen_parameters_t0_nr(cs->slot_nr, get_icc_status(cs), seq, cmd_sts, err, t0); |
| 176 | } |
| 177 | |
| 178 | static struct msgb *ccid_gen_parameters_t1_nr(uint8_t slot_nr, uint8_t icc_status, |
| 179 | uint8_t seq, uint8_t cmd_sts, enum ccid_error_code err, |
| 180 | const struct ccid_proto_data_t1 *t1) |
| 181 | { |
| 182 | struct msgb *msg = ccid_msgb_alloc(); |
| 183 | struct ccid_rdr_to_pc_parameters *par = |
| 184 | (struct ccid_rdr_to_pc_parameters *) msgb_put(msg, sizeof(par->hdr)+sizeof(*t1)); |
| 185 | uint8_t sts = (cmd_sts & CCID_CMD_STATUS_MASK) | icc_status; |
| 186 | |
| 187 | SET_HDR_IN(par, RDR_to_PC_Parameters, slot_nr, seq, sts, err); |
| 188 | if (t1) { |
| 189 | osmo_store32le(sizeof(*t1), &par->hdr.hdr.dwLength); |
| 190 | par->abProtocolData.t1 = *t1; |
| 191 | } |
| 192 | return msg; |
| 193 | } |
| 194 | static struct msgb *ccid_gen_parameters_t1(struct ccid_slot *cs, uint8_t seq, uint8_t cmd_sts, |
| 195 | enum ccid_error_code err, |
| 196 | const struct ccid_proto_data_t1 *t1) |
| 197 | { |
| 198 | return ccid_gen_parameters_t1_nr(cs->slot_nr, get_icc_status(cs), seq, cmd_sts, err, t1); |
| 199 | } |
| 200 | |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 201 | |
| 202 | /* Section 6.2.4 */ |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 203 | static struct msgb *ccid_gen_escape_nr(uint8_t slot_nr, uint8_t icc_status, uint8_t seq, uint8_t cmd_sts, |
| 204 | enum ccid_error_code err, const uint8_t *data, uint32_t data_len) |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 205 | { |
| 206 | struct msgb *msg = ccid_msgb_alloc(); |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 207 | struct ccid_rdr_to_pc_escape *esc = |
| 208 | (struct ccid_rdr_to_pc_escape *) msgb_put(msg, sizeof(*esc) + data_len); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 209 | uint8_t sts = (cmd_sts & CCID_CMD_STATUS_MASK) | icc_status; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 210 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 211 | SET_HDR_IN(esc, RDR_to_PC_Escape, slot_nr, seq, sts, err); |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 212 | osmo_store32le(data_len, &esc->hdr.hdr.dwLength); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 213 | memcpy(esc->abData, data, data_len); |
| 214 | return msg; |
| 215 | } |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 216 | static struct msgb *ccid_gen_escape(struct ccid_slot *cs, uint8_t seq, uint8_t cmd_sts, |
| 217 | enum ccid_error_code err, const uint8_t *data, |
| 218 | uint32_t data_len) |
| 219 | { |
| 220 | return ccid_gen_escape_nr(cs->slot_nr, get_icc_status(cs), seq, cmd_sts, err, data, data_len); |
| 221 | } |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 222 | |
| 223 | /* Section 6.2.5 */ |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 224 | static struct msgb *ccid_gen_clock_and_rate_nr(uint8_t slot_nr, uint8_t icc_status, uint8_t seq, |
| 225 | uint8_t cmd_sts, enum ccid_error_code err, |
| 226 | uint32_t clock_khz, uint32_t rate_bps) |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 227 | { |
| 228 | struct msgb *msg = ccid_msgb_alloc(); |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 229 | struct ccid_rdr_to_pc_data_rate_and_clock *drc = |
| 230 | (struct ccid_rdr_to_pc_data_rate_and_clock *) msgb_put(msg, sizeof(*drc)); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 231 | uint8_t sts = (cmd_sts & CCID_CMD_STATUS_MASK) | icc_status; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 232 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 233 | SET_HDR_IN(drc, RDR_to_PC_DataRateAndClockFrequency, slot_nr, seq, sts, err); |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 234 | osmo_store32le(8, &drc->hdr.hdr.dwLength); /* Message-specific data length (wtf?) */ |
| 235 | osmo_store32le(clock_khz, &drc->dwClockFrequency); /* kHz */ |
| 236 | osmo_store32le(rate_bps, &drc->dwDataRate); /* bps */ |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 237 | return msg; |
| 238 | } |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 239 | static struct msgb *ccid_gen_clock_and_rate(struct ccid_slot *cs, uint8_t seq, uint8_t cmd_sts, |
| 240 | enum ccid_error_code err, uint32_t clock_khz, |
| 241 | uint32_t rate_bps) |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 242 | { |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 243 | return ccid_gen_clock_and_rate_nr(cs->slot_nr, get_icc_status(cs), seq, cmd_sts, err, |
| 244 | clock_khz, rate_bps); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 245 | } |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 246 | |
| 247 | /*! generate an error response for given input message_type/slot_nr/seq |
| 248 | * \param[in] msg_type CCID Message Type against which response is to be created |
| 249 | * \param[in] slot_nr CCID Slot Number |
| 250 | * \param[in] icc_status ICC Status of the slot |
| 251 | * \param[in] seq CCID Sequence number |
| 252 | * \param[in] err_code CCID Error Code to send |
| 253 | * \returns dynamically-allocated message buffer containing error response */ |
| 254 | static struct msgb *gen_err_resp(enum ccid_msg_type msg_type, uint8_t slot_nr, uint8_t icc_status, |
| 255 | uint8_t seq, enum ccid_error_code err_code) |
| 256 | { |
| 257 | struct msgb *resp = NULL; |
| 258 | |
| 259 | switch (msg_type) { |
| 260 | case PC_to_RDR_IccPowerOn: |
| 261 | case PC_to_RDR_XfrBlock: |
| 262 | case PC_to_RDR_Secure: |
| 263 | /* Return RDR_to_PC_DataBlock */ |
| 264 | resp = ccid_gen_data_block_nr(slot_nr, icc_status, seq, CCID_CMD_STATUS_FAILED, |
| 265 | err_code, NULL, 0); |
| 266 | break; |
| 267 | |
| 268 | case PC_to_RDR_IccPowerOff: |
| 269 | case PC_to_RDR_GetSlotStatus: |
| 270 | case PC_to_RDR_IccClock: |
| 271 | case PC_to_RDR_T0APDU: |
| 272 | case PC_to_RDR_Mechanical: |
| 273 | case PC_to_RDR_Abort: |
| 274 | /* Return RDR_to_PC_SlotStatus */ |
| 275 | resp = ccid_gen_slot_status_nr(slot_nr, icc_status, seq, CCID_CMD_STATUS_FAILED, |
| 276 | err_code); |
| 277 | break; |
| 278 | |
| 279 | case PC_to_RDR_GetParameters: |
| 280 | case PC_to_RDR_ResetParameters: |
| 281 | case PC_to_RDR_SetParameters: |
| 282 | /* Return RDR_to_PC_Parameters */ |
| 283 | resp = ccid_gen_parameters_t0_nr(slot_nr, icc_status, seq, CCID_CMD_STATUS_FAILED, |
| 284 | err_code, NULL); /* FIXME: parameters? */ |
| 285 | break; |
| 286 | |
| 287 | case PC_to_RDR_Escape: |
| 288 | /* Return RDR_to_PC_Escape */ |
| 289 | resp = ccid_gen_escape_nr(slot_nr, icc_status, seq, CCID_CMD_STATUS_FAILED, |
| 290 | err_code, NULL, 0); |
| 291 | break; |
| 292 | |
| 293 | case PC_to_RDR_SetDataRateAndClockFrequency: |
| 294 | /* Return RDR_to_PC_SlotStatus */ |
| 295 | resp = ccid_gen_slot_status_nr(slot_nr, icc_status, seq, CCID_CMD_STATUS_FAILED, |
| 296 | err_code); |
| 297 | break; |
| 298 | |
| 299 | default: |
| 300 | /* generate general error */ |
| 301 | resp = ccid_gen_slot_status_nr(slot_nr, icc_status, seq, CCID_CMD_STATUS_FAILED, |
| 302 | CCID_ERR_CMD_NOT_SUPPORTED); |
| 303 | break; |
| 304 | } |
| 305 | return resp; |
| 306 | } |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 307 | |
| 308 | /*********************************************************************** |
| 309 | * Message reception / parsing |
| 310 | ***********************************************************************/ |
| 311 | |
| 312 | /* Section 6.1.3 */ |
| 313 | static int ccid_handle_get_slot_status(struct ccid_slot *cs, struct msgb *msg) |
| 314 | { |
| 315 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 316 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 317 | uint8_t seq = u->get_slot_status.hdr.bSeq; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 318 | struct msgb *resp; |
| 319 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 320 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_OK, 0); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 321 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 322 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | |
| 326 | /* Section 6.1.1 */ |
| 327 | static int ccid_handle_icc_power_on(struct ccid_slot *cs, struct msgb *msg) |
| 328 | { |
| 329 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 330 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 331 | uint8_t seq = u->icc_power_on.hdr.bSeq; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 332 | struct msgb *resp; |
| 333 | |
| 334 | /* TODO: send actual ATR; handle error cases */ |
| 335 | /* TODO: handle this asynchronously */ |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 336 | resp = ccid_gen_data_block(cs, seq, CCID_CMD_STATUS_OK, 0, NULL, 0); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 337 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 338 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | /* Section 6.1.2 */ |
| 342 | static int ccid_handle_icc_power_off(struct ccid_slot *cs, struct msgb *msg) |
| 343 | { |
| 344 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 345 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 346 | uint8_t seq = u->icc_power_off.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 347 | struct msgb *resp; |
| 348 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 349 | /* FIXME */ |
| 350 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_OK, 0); |
| 351 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | /* Section 6.1.4 */ |
| 355 | static int ccid_handle_xfr_block(struct ccid_slot *cs, struct msgb *msg) |
| 356 | { |
| 357 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 358 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 359 | uint8_t seq = u->xfr_block.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 360 | struct msgb *resp; |
| 361 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 362 | /* FIXME */ |
| 363 | resp = ccid_gen_data_block(cs, seq, CCID_CMD_STATUS_OK, 0, NULL, 0); |
| 364 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /* Section 6.1.5 */ |
| 368 | static int ccid_handle_get_parameters(struct ccid_slot *cs, struct msgb *msg) |
| 369 | { |
| 370 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 371 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 372 | uint8_t seq = u->get_parameters.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 373 | struct msgb *resp; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 374 | |
| 375 | /* FIXME */ |
| 376 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | /* Section 6.1.6 */ |
| 380 | static int ccid_handle_reset_parameters(struct ccid_slot *cs, struct msgb *msg) |
| 381 | { |
| 382 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 383 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 384 | uint8_t seq = u->reset_parameters.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 385 | struct msgb *resp; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 386 | |
| 387 | /* FIXME */ |
| 388 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | /* Section 6.1.7 */ |
| 392 | static int ccid_handle_set_parameters(struct ccid_slot *cs, struct msgb *msg) |
| 393 | { |
| 394 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 395 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 396 | uint8_t seq = u->set_parameters.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 397 | struct msgb *resp; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 398 | |
| 399 | /* FIXME */ |
| 400 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | /* Section 6.1.8 */ |
| 404 | static int ccid_handle_escape(struct ccid_slot *cs, struct msgb *msg) |
| 405 | { |
| 406 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 407 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 408 | uint8_t seq = u->escape.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 409 | struct msgb *resp; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 410 | |
| 411 | resp = ccid_gen_escape(cs, seq, CCID_CMD_STATUS_FAILED, CCID_ERR_CMD_NOT_SUPPORTED, NULL, 0); |
| 412 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | /* Section 6.1.9 */ |
| 416 | static int ccid_handle_icc_clock(struct ccid_slot *cs, struct msgb *msg) |
| 417 | { |
| 418 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 419 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 420 | uint8_t seq = u->icc_clock.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 421 | struct msgb *resp; |
| 422 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 423 | /* FIXME: Actually Stop/Start the clock */ |
| 424 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_OK, 0); |
| 425 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /* Section 6.1.10 */ |
| 429 | static int ccid_handle_t0apdu(struct ccid_slot *cs, struct msgb *msg) |
| 430 | { |
| 431 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 432 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 433 | uint8_t seq = u->t0apdu.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 434 | struct msgb *resp; |
| 435 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 436 | /* FIXME */ |
| 437 | //resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_OK, 0); |
| 438 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_FAILED, CCID_ERR_CMD_NOT_SUPPORTED); |
| 439 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | /* Section 6.1.11 */ |
| 443 | static int ccid_handle_secure(struct ccid_slot *cs, struct msgb *msg) |
| 444 | { |
| 445 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 446 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 447 | uint8_t seq = u->secure.hdr.bSeq; |
| 448 | struct msgb *resp; |
| 449 | |
| 450 | /* FIXME */ |
| 451 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_FAILED, CCID_ERR_CMD_NOT_SUPPORTED); |
| 452 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | /* Section 6.1.12 */ |
| 456 | static int ccid_handle_mechanical(struct ccid_slot *cs, struct msgb *msg) |
| 457 | { |
| 458 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 459 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 460 | uint8_t seq = u->mechanical.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 461 | struct msgb *resp; |
| 462 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 463 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_FAILED, CCID_ERR_CMD_NOT_SUPPORTED); |
| 464 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | /* Section 6.1.13 */ |
| 468 | static int ccid_handle_abort(struct ccid_slot *cs, struct msgb *msg) |
| 469 | { |
| 470 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 471 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 472 | uint8_t seq = u->abort.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 473 | struct msgb *resp; |
| 474 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 475 | /* Check if the currently in-progress message is Abortable */ |
| 476 | switch (0/* FIXME */) { |
| 477 | case PC_to_RDR_IccPowerOn: |
| 478 | case PC_to_RDR_XfrBlock: |
| 479 | case PC_to_RDR_Escape: |
| 480 | case PC_to_RDR_Secure: |
| 481 | case PC_to_RDR_Mechanical: |
| 482 | //case PC_to_RDR_Abort: /* seriously? WTF! */ |
| 483 | break; |
| 484 | default: |
| 485 | /* CCID spec lists CMD_NOT_ABORTED, but gives no numberic value ?!? */ |
| 486 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_FAILED, CCID_ERR_CMD_NOT_SUPPORTED); |
| 487 | return ccid_slot_send_unbusy(cs, resp); |
| 488 | } |
| 489 | |
| 490 | /* FIXME */ |
| 491 | resp = ccid_gen_slot_status(cs, seq, CCID_CMD_STATUS_OK, 0); |
| 492 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | /* Section 6.1.14 */ |
| 496 | static int ccid_handle_set_rate_and_clock(struct ccid_slot *cs, struct msgb *msg) |
| 497 | { |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 498 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 499 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 500 | uint8_t seq = u->set_rate_and_clock.hdr.bSeq; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 501 | struct msgb *resp; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 502 | |
| 503 | /* FIXME */ |
| 504 | resp = ccid_gen_clock_and_rate(cs, seq, CCID_CMD_STATUS_OK, 0, 9600, 2500000); |
| 505 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 506 | } |
| 507 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 508 | /*! Handle data arriving from the host on the OUT endpoint. |
| 509 | * \param[in] cs CCID Instance on which to operate |
| 510 | * \param[in] msgb received message buffer containing one CCID OUT EP message from the host |
| 511 | * \returns 0 on success; negative on error */ |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 512 | int ccid_handle_out(struct ccid_instance *ci, struct msgb *msg) |
| 513 | { |
| 514 | const union ccid_pc_to_rdr *u = msgb_ccid_out(msg); |
| 515 | const struct ccid_header *ch = (const struct ccid_header *) u; |
| 516 | unsigned int len = msgb_length(msg); |
| 517 | struct ccid_slot *cs; |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 518 | struct msgb *resp; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 519 | int rc; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 520 | |
| 521 | if (len < sizeof(*ch)) { |
| 522 | /* FIXME */ |
| 523 | return -1; |
| 524 | } |
| 525 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 526 | /* Check for invalid slot number */ |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 527 | cs = get_ccid_slot(ci, ch->bSlot); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 528 | if (!cs) { |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 529 | resp = gen_err_resp(ch->bMessageType, ch->bSlot, CCID_ICC_STATUS_NO_ICC, ch->bSeq, 5); |
| 530 | return ccid_send(ci, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 531 | } |
| 532 | |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 533 | /* Check if slot is already busy; Reject any additional commands meanwhile */ |
| 534 | if (cs->cmd_busy) { |
| 535 | /* FIXME: ABORT logic as per section 5.3.1 of CCID Spec v1.1 */ |
| 536 | resp = gen_err_resp(ch->bMessageType, ch->bSlot, get_icc_status(cs), ch->bSeq, |
| 537 | CCID_ERR_CMD_SLOT_BUSY); |
| 538 | return ccid_send(ci, resp); |
| 539 | } |
| 540 | |
| 541 | /* we're now processing a command for the slot; mark slot as busy */ |
| 542 | cs->cmd_busy = true; |
| 543 | |
| 544 | /* TODO: enqueue into the per-slot specific input queue */ |
| 545 | |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 546 | switch (ch->bMessageType) { |
| 547 | case PC_to_RDR_GetSlotStatus: |
| 548 | if (len != sizeof(u->get_slot_status)) |
| 549 | goto short_msg; |
| 550 | rc = ccid_handle_get_slot_status(cs, msg); |
| 551 | break; |
| 552 | case PC_to_RDR_IccPowerOn: |
| 553 | if (len != sizeof(u->icc_power_on)) |
| 554 | goto short_msg; |
| 555 | rc = ccid_handle_icc_power_on(cs, msg); |
| 556 | break; |
| 557 | case PC_to_RDR_IccPowerOff: |
| 558 | if (len != sizeof(u->icc_power_off)) |
| 559 | goto short_msg; |
| 560 | rc = ccid_handle_icc_power_off(cs, msg); |
| 561 | break; |
| 562 | case PC_to_RDR_XfrBlock: |
| 563 | if (len < sizeof(u->xfr_block)) |
| 564 | goto short_msg; |
| 565 | rc = ccid_handle_xfr_block(cs, msg); |
| 566 | break; |
| 567 | case PC_to_RDR_GetParameters: |
| 568 | if (len != sizeof(u->get_parameters)) |
| 569 | goto short_msg; |
| 570 | rc = ccid_handle_get_parameters(cs, msg); |
| 571 | break; |
| 572 | case PC_to_RDR_ResetParameters: |
| 573 | if (len != sizeof(u->reset_parameters)) |
| 574 | goto short_msg; |
| 575 | rc = ccid_handle_reset_parameters(cs, msg); |
| 576 | break; |
| 577 | case PC_to_RDR_SetParameters: |
| 578 | if (len != sizeof(u->set_parameters)) |
| 579 | goto short_msg; |
| 580 | rc = ccid_handle_set_parameters(cs, msg); |
| 581 | break; |
| 582 | case PC_to_RDR_Escape: |
| 583 | if (len < sizeof(u->escape)) |
| 584 | goto short_msg; |
| 585 | rc = ccid_handle_escape(cs, msg); |
| 586 | break; |
| 587 | case PC_to_RDR_IccClock: |
| 588 | if (len != sizeof(u->icc_clock)) |
| 589 | goto short_msg; |
| 590 | rc = ccid_handle_icc_clock(cs, msg); |
| 591 | break; |
| 592 | case PC_to_RDR_T0APDU: |
| 593 | if (len != /*FIXME*/ sizeof(u->t0apdu)) |
| 594 | goto short_msg; |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 595 | rc = ccid_handle_t0apdu(cs, msg); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 596 | break; |
| 597 | case PC_to_RDR_Secure: |
| 598 | if (len < sizeof(u->secure)) |
| 599 | goto short_msg; |
| 600 | rc = ccid_handle_secure(cs, msg); |
| 601 | break; |
| 602 | case PC_to_RDR_Mechanical: |
| 603 | if (len != sizeof(u->mechanical)) |
| 604 | goto short_msg; |
| 605 | rc = ccid_handle_mechanical(cs, msg); |
| 606 | break; |
| 607 | case PC_to_RDR_Abort: |
| 608 | if (len != sizeof(u->abort)) |
| 609 | goto short_msg; |
| 610 | rc = ccid_handle_abort(cs, msg); |
| 611 | break; |
| 612 | case PC_to_RDR_SetDataRateAndClockFrequency: |
| 613 | if (len != sizeof(u->set_rate_and_clock)) |
| 614 | goto short_msg; |
| 615 | rc = ccid_handle_set_rate_and_clock(cs, msg); |
| 616 | break; |
| 617 | default: |
Harald Welte | 8772f58 | 2019-05-14 16:34:47 +0200 | [diff] [blame^] | 618 | /* generic response with bERror = 0 (command not supported) */ |
| 619 | resp = gen_err_resp(ch->bMessageType, ch->bSlot, CCID_ICC_STATUS_NO_ICC, ch->bSeq, |
| 620 | CCID_ERR_CMD_NOT_SUPPORTED); |
| 621 | return ccid_slot_send_unbusy(cs, resp); |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 622 | } |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 623 | return 0; |
| 624 | |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 625 | short_msg: |
Harald Welte | 92e7c0b | 2019-05-14 09:32:10 +0200 | [diff] [blame] | 626 | /* FIXME */ |
| 627 | return -1; |
Harald Welte | 6365374 | 2019-01-03 16:54:16 +0100 | [diff] [blame] | 628 | } |