Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 1 | /* Test Osmocom Authentication Protocol */ |
| 2 | /* |
| 3 | * (C) 2015 by sysmocom s.f.m.c. GmbH |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Affero General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU Affero General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Affero General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #include <osmocom/core/application.h> |
Harald Welte | 736474c | 2016-05-06 23:28:52 +0200 | [diff] [blame] | 22 | #include <osmocom/gsm/oap.h> |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 23 | |
| 24 | #include <openbsc/debug.h> |
Neels Hofmeyr | 11ecc93 | 2016-12-08 21:29:23 +0100 | [diff] [blame] | 25 | #include <openbsc/oap_client.h> |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 26 | |
| 27 | #include <stdio.h> |
Harald Welte | 31760a1 | 2016-04-27 15:17:14 +0200 | [diff] [blame] | 28 | #include <string.h> |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 29 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 30 | static void test_oap_api(void) |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 31 | { |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 32 | printf("Testing OAP API\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 33 | |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 34 | struct oap_client_config _config; |
| 35 | struct oap_client_config *config = &_config; |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 36 | |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 37 | struct oap_client_state _state; |
| 38 | struct oap_client_state *state = &_state; |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 39 | |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame^] | 40 | struct osmo_oap_message oap_rx; |
| 41 | struct msgb *msg_rx; |
| 42 | |
| 43 | struct osmo_oap_message oap_tx; |
| 44 | struct msgb *msg_tx; |
| 45 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 46 | memset(config, 0, sizeof(*config)); |
| 47 | memset(state, 0, sizeof(*state)); |
| 48 | |
| 49 | OSMO_ASSERT(osmo_hexparse("0102030405060708090a0b0c0d0e0f10", config->secret_k, 16) == 16); |
| 50 | OSMO_ASSERT(osmo_hexparse("1112131415161718191a1b1c1d1e1f20", config->secret_opc, 16) == 16); |
| 51 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 52 | fprintf(stderr, "- make sure filling with zeros means uninitialized\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 53 | OSMO_ASSERT(state->state == OAP_UNINITIALIZED); |
| 54 | |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame^] | 55 | fprintf(stderr, "- reject messages in uninitialized state EXPECTING BUGS\n"); |
| 56 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 57 | state->client_id = 1; |
| 58 | oap_rx.message_type = OAP_MSGT_REGISTER_ERROR; |
| 59 | msg_rx = oap_client_encoded(&oap_rx); |
| 60 | /* ATTENTION: This shows a bug in OAP: the rc should be < 0, but OAP |
| 61 | * happily accepts this message and breaks the uninitialized state. The |
| 62 | * expected rc, state and msg_tx will be fixed along with the fix. */ |
| 63 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0 /* BUG, expecting < 0 */); |
| 64 | OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE /* BUG, expecting OAP_UNINITIALIZED */); |
| 65 | msgb_free(msg_rx); |
| 66 | OSMO_ASSERT(msg_tx /* BUG, expecting NULL */); |
| 67 | msgb_free(msg_tx); |
| 68 | |
| 69 | fprintf(stderr, "- reject messages in disabled state\n"); |
| 70 | memset(state, 0, sizeof(*state)); |
| 71 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 72 | state->state = OAP_DISABLED; |
| 73 | state->client_id = 1; |
| 74 | oap_rx.message_type = OAP_MSGT_REGISTER_ERROR; |
| 75 | msg_rx = oap_client_encoded(&oap_rx); |
| 76 | /* ATTENTION: This shows a bug in OAP: the rc should be < 0, but OAP |
| 77 | * happily accepts this message and breaks the uninitialized state. The |
| 78 | * expected rc, state and msg_tx will be fixed along with the fix. */ |
| 79 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0 /* BUG, expecting < 0 */); |
| 80 | OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE /* BUG, expecting OAP_DISABLED */); |
| 81 | msgb_free(msg_rx); |
| 82 | OSMO_ASSERT(msg_tx /* BUG, expecting NULL */); |
| 83 | msgb_free(msg_tx); |
| 84 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 85 | fprintf(stderr, "- invalid client_id and shared secret\n"); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame^] | 86 | memset(state, 0, sizeof(*state)); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 87 | config->client_id = 0; |
| 88 | config->secret_k_present = 0; |
| 89 | config->secret_opc_present = 0; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 90 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 91 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 92 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 93 | fprintf(stderr, "- reset state\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 94 | memset(state, 0, sizeof(*state)); |
| 95 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 96 | fprintf(stderr, "- only client_id is invalid\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 97 | config->client_id = 0; |
| 98 | config->secret_k_present = 1; |
| 99 | config->secret_opc_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 100 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 101 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 102 | |
| 103 | memset(state, 0, sizeof(*state)); |
| 104 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 105 | fprintf(stderr, "- valid id, but omitted shared_secret (1/2)\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 106 | config->client_id = 12345; |
| 107 | config->secret_k_present = 0; |
| 108 | config->secret_opc_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 109 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 110 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 111 | |
| 112 | memset(state, 0, sizeof(*state)); |
| 113 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 114 | fprintf(stderr, "- valid id, but omitted shared_secret (2/2)\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 115 | config->client_id = 12345; |
| 116 | config->secret_k_present = 1; |
| 117 | config->secret_opc_present = 0; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 118 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 119 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 120 | |
| 121 | memset(state, 0, sizeof(*state)); |
| 122 | |
| 123 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 124 | fprintf(stderr, "- mint configuration\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 125 | config->client_id = 12345; |
| 126 | config->secret_k_present = 1; |
| 127 | config->secret_opc_present = 1; |
| 128 | /*config->secret_* buffers are still set from the top */ |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 129 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 130 | OSMO_ASSERT(state->state == OAP_INITIALIZED); |
| 131 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 132 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 133 | fprintf(stderr, "- Missing challenge data\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 134 | memset(&oap_rx, 0, sizeof(oap_rx)); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 135 | oap_rx.message_type = OAP_MSGT_CHALLENGE_REQUEST; |
| 136 | oap_rx.rand_present = 0; |
| 137 | oap_rx.autn_present = 0; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 138 | msg_rx = oap_client_encoded(&oap_rx); |
| 139 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 140 | msgb_free(msg_rx); |
| 141 | OSMO_ASSERT(!msg_tx); |
| 142 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 143 | fprintf(stderr, "- AUTN missing\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 144 | osmo_hexparse("0102030405060708090a0b0c0d0e0f10", |
| 145 | oap_rx.rand, 16); |
| 146 | oap_rx.rand_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 147 | msg_rx = oap_client_encoded(&oap_rx); |
| 148 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 149 | msgb_free(msg_rx); |
| 150 | OSMO_ASSERT(!msg_tx); |
| 151 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 152 | fprintf(stderr, "- RAND missing\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 153 | oap_rx.rand_present = 0; |
| 154 | osmo_hexparse("cec4e3848a33000086781158ca40f136", |
| 155 | oap_rx.autn, 16); |
| 156 | oap_rx.autn_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 157 | msg_rx = oap_client_encoded(&oap_rx); |
| 158 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 159 | msgb_free(msg_rx); |
| 160 | OSMO_ASSERT(!msg_tx); |
| 161 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 162 | fprintf(stderr, "- wrong autn (by one bit)\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 163 | osmo_hexparse("0102030405060708090a0b0c0d0e0f10", |
| 164 | oap_rx.rand, 16); |
| 165 | osmo_hexparse("dec4e3848a33000086781158ca40f136", |
| 166 | oap_rx.autn, 16); |
| 167 | oap_rx.rand_present = 1; |
| 168 | oap_rx.autn_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 169 | msg_rx = oap_client_encoded(&oap_rx); |
| 170 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 171 | msgb_free(msg_rx); |
| 172 | OSMO_ASSERT(!msg_tx); |
| 173 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 174 | fprintf(stderr, "- all data correct\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 175 | osmo_hexparse("cec4e3848a33000086781158ca40f136", |
| 176 | oap_rx.autn, 16); |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 177 | msg_rx = oap_client_encoded(&oap_rx); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 178 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 179 | fprintf(stderr, "- but refuse to evaluate in uninitialized state\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 180 | OSMO_ASSERT(state->state == OAP_INITIALIZED); |
| 181 | |
| 182 | state->state = OAP_UNINITIALIZED; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 183 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -1); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 184 | OSMO_ASSERT(!msg_tx); |
| 185 | |
| 186 | state->state = OAP_DISABLED; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 187 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -1); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 188 | OSMO_ASSERT(!msg_tx); |
| 189 | |
| 190 | state->state = OAP_INITIALIZED; |
| 191 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 192 | fprintf(stderr, "- now everything is correct\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 193 | /* a successful return value here indicates correct autn */ |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 194 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 195 | msgb_free(msg_rx); |
| 196 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 197 | fprintf(stderr, "- Expect the challenge response in msg_tx\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 198 | OSMO_ASSERT(msg_tx); |
Harald Welte | 5d547a4 | 2016-04-27 18:21:16 +0200 | [diff] [blame] | 199 | OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 200 | OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_CHALLENGE_RESULT); |
| 201 | OSMO_ASSERT(strcmp("e2d05b598c61d9ba", |
| 202 | osmo_hexdump_nospc(oap_tx.xres, sizeof(oap_tx.xres))) |
| 203 | == 0); |
| 204 | OSMO_ASSERT(state->state == OAP_SENT_CHALLENGE_RESULT); |
| 205 | msgb_free(msg_tx); |
| 206 | msg_tx = 0; |
| 207 | |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 208 | struct oap_client_state saved_state = _state; |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 209 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 210 | fprintf(stderr, "- Receive registration error for the first time.\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 211 | |
| 212 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 213 | oap_rx.message_type = OAP_MSGT_REGISTER_ERROR; |
| 214 | oap_rx.cause = GMM_CAUSE_PROTO_ERR_UNSPEC; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 215 | msg_rx = oap_client_encoded(&oap_rx); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 216 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 217 | OSMO_ASSERT(state->registration_failures == 0); |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 218 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 219 | OSMO_ASSERT(state->registration_failures == 1); |
| 220 | OSMO_ASSERT(msg_tx); |
Harald Welte | 5d547a4 | 2016-04-27 18:21:16 +0200 | [diff] [blame] | 221 | OSMO_ASSERT(osmo_oap_decode(&oap_tx, msg_tx->data, msg_tx->len) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 222 | OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_REGISTER_REQUEST); |
| 223 | OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE); |
| 224 | msgb_free(msg_tx); |
| 225 | msg_tx = 0; |
| 226 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 227 | fprintf(stderr, "- Receive registration error for the Nth time.\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 228 | state->registration_failures = 999; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 229 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -11); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 230 | OSMO_ASSERT(!msg_tx); |
| 231 | OSMO_ASSERT(state->state == OAP_INITIALIZED); |
| 232 | msgb_free(msg_tx); |
| 233 | msg_tx = 0; |
| 234 | |
| 235 | msgb_free(msg_rx); |
| 236 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 237 | fprintf(stderr, "- Registration success\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 238 | |
| 239 | _state = saved_state; |
| 240 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 241 | oap_rx.message_type = OAP_MSGT_REGISTER_RESULT; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 242 | msg_rx = oap_client_encoded(&oap_rx); |
| 243 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 244 | OSMO_ASSERT(!msg_tx); |
| 245 | OSMO_ASSERT(state->state == OAP_REGISTERED); |
| 246 | msgb_free(msg_rx); |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 247 | } |
| 248 | |
Neels Hofmeyr | 73ed455 | 2016-12-09 00:01:56 +0100 | [diff] [blame] | 249 | static struct log_info_cat oap_client_test_categories[] = { |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | static struct log_info info = { |
Neels Hofmeyr | 73ed455 | 2016-12-09 00:01:56 +0100 | [diff] [blame] | 253 | .cat = oap_client_test_categories, |
| 254 | .num_cat = ARRAY_SIZE(oap_client_test_categories), |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 255 | }; |
| 256 | |
| 257 | int main(int argc, char **argv) |
| 258 | { |
Neels Hofmeyr | 4c2d4ab | 2016-09-16 02:31:17 +0200 | [diff] [blame] | 259 | msgb_talloc_ctx_init(NULL, 0); |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 260 | osmo_init_logging(&info); |
| 261 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 262 | OSMO_ASSERT(osmo_stderr_target); |
Neels Hofmeyr | 73ed455 | 2016-12-09 00:01:56 +0100 | [diff] [blame] | 263 | log_set_use_color(osmo_stderr_target, 0); |
| 264 | log_set_print_timestamp(osmo_stderr_target, 0); |
| 265 | log_set_print_filename(osmo_stderr_target, 0); |
| 266 | log_set_print_category(osmo_stderr_target, 1); |
| 267 | log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 268 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 269 | test_oap_api(); |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 270 | printf("Done\n"); |
| 271 | |
| 272 | return 0; |
| 273 | } |
| 274 | |