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 | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 55 | fprintf(stderr, "- reject messages in uninitialized state\n"); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame] | 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); |
Neels Hofmeyr | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 60 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0); |
| 61 | OSMO_ASSERT(state->state == OAP_UNINITIALIZED); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame] | 62 | msgb_free(msg_rx); |
Neels Hofmeyr | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 63 | OSMO_ASSERT(!msg_tx); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame] | 64 | |
| 65 | fprintf(stderr, "- reject messages in disabled state\n"); |
| 66 | memset(state, 0, sizeof(*state)); |
| 67 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 68 | state->state = OAP_DISABLED; |
| 69 | state->client_id = 1; |
| 70 | oap_rx.message_type = OAP_MSGT_REGISTER_ERROR; |
| 71 | msg_rx = oap_client_encoded(&oap_rx); |
Neels Hofmeyr | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 72 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0); |
| 73 | OSMO_ASSERT(state->state == OAP_DISABLED); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame] | 74 | msgb_free(msg_rx); |
Neels Hofmeyr | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 75 | OSMO_ASSERT(!msg_tx); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame] | 76 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 77 | fprintf(stderr, "- invalid client_id and shared secret\n"); |
Neels Hofmeyr | 3cbc052 | 2016-12-08 23:13:29 +0100 | [diff] [blame] | 78 | memset(state, 0, sizeof(*state)); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 79 | config->client_id = 0; |
| 80 | config->secret_k_present = 0; |
| 81 | config->secret_opc_present = 0; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 82 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 83 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 84 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 85 | fprintf(stderr, "- reset state\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 86 | memset(state, 0, sizeof(*state)); |
| 87 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 88 | fprintf(stderr, "- only client_id is invalid\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 89 | config->client_id = 0; |
| 90 | config->secret_k_present = 1; |
| 91 | config->secret_opc_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 92 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 93 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 94 | |
| 95 | memset(state, 0, sizeof(*state)); |
| 96 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 97 | fprintf(stderr, "- valid id, but omitted shared_secret (1/2)\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 98 | config->client_id = 12345; |
| 99 | config->secret_k_present = 0; |
| 100 | config->secret_opc_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 101 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 102 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 103 | |
| 104 | memset(state, 0, sizeof(*state)); |
| 105 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 106 | fprintf(stderr, "- valid id, but omitted shared_secret (2/2)\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 107 | config->client_id = 12345; |
| 108 | config->secret_k_present = 1; |
| 109 | config->secret_opc_present = 0; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 110 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 111 | OSMO_ASSERT(state->state == OAP_DISABLED); |
| 112 | |
| 113 | memset(state, 0, sizeof(*state)); |
| 114 | |
| 115 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 116 | fprintf(stderr, "- mint configuration\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 117 | config->client_id = 12345; |
| 118 | config->secret_k_present = 1; |
| 119 | config->secret_opc_present = 1; |
| 120 | /*config->secret_* buffers are still set from the top */ |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 121 | OSMO_ASSERT( oap_client_init(config, state) == 0 ); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 122 | OSMO_ASSERT(state->state == OAP_INITIALIZED); |
| 123 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 124 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 125 | fprintf(stderr, "- Missing challenge data\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 126 | memset(&oap_rx, 0, sizeof(oap_rx)); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 127 | oap_rx.message_type = OAP_MSGT_CHALLENGE_REQUEST; |
| 128 | oap_rx.rand_present = 0; |
| 129 | oap_rx.autn_present = 0; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 130 | msg_rx = oap_client_encoded(&oap_rx); |
| 131 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 132 | msgb_free(msg_rx); |
| 133 | OSMO_ASSERT(!msg_tx); |
| 134 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 135 | fprintf(stderr, "- AUTN missing\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 136 | osmo_hexparse("0102030405060708090a0b0c0d0e0f10", |
| 137 | oap_rx.rand, 16); |
| 138 | oap_rx.rand_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 139 | msg_rx = oap_client_encoded(&oap_rx); |
| 140 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 141 | msgb_free(msg_rx); |
| 142 | OSMO_ASSERT(!msg_tx); |
| 143 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 144 | fprintf(stderr, "- RAND missing\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 145 | oap_rx.rand_present = 0; |
| 146 | osmo_hexparse("cec4e3848a33000086781158ca40f136", |
| 147 | oap_rx.autn, 16); |
| 148 | oap_rx.autn_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 149 | msg_rx = oap_client_encoded(&oap_rx); |
| 150 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 151 | msgb_free(msg_rx); |
| 152 | OSMO_ASSERT(!msg_tx); |
| 153 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 154 | fprintf(stderr, "- wrong autn (by one bit)\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 155 | osmo_hexparse("0102030405060708090a0b0c0d0e0f10", |
| 156 | oap_rx.rand, 16); |
| 157 | osmo_hexparse("dec4e3848a33000086781158ca40f136", |
| 158 | oap_rx.autn, 16); |
| 159 | oap_rx.rand_present = 1; |
| 160 | oap_rx.autn_present = 1; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 161 | msg_rx = oap_client_encoded(&oap_rx); |
| 162 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -2); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 163 | msgb_free(msg_rx); |
| 164 | OSMO_ASSERT(!msg_tx); |
| 165 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 166 | fprintf(stderr, "- all data correct\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 167 | osmo_hexparse("cec4e3848a33000086781158ca40f136", |
| 168 | oap_rx.autn, 16); |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 169 | msg_rx = oap_client_encoded(&oap_rx); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 170 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 171 | fprintf(stderr, "- but refuse to evaluate in uninitialized state\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 172 | OSMO_ASSERT(state->state == OAP_INITIALIZED); |
| 173 | |
| 174 | state->state = OAP_UNINITIALIZED; |
Neels Hofmeyr | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 175 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 176 | OSMO_ASSERT(!msg_tx); |
| 177 | |
| 178 | state->state = OAP_DISABLED; |
Neels Hofmeyr | 2fa74fa | 2016-12-08 23:12:17 +0100 | [diff] [blame^] | 179 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) < 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 180 | OSMO_ASSERT(!msg_tx); |
| 181 | |
| 182 | state->state = OAP_INITIALIZED; |
| 183 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 184 | fprintf(stderr, "- now everything is correct\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 185 | /* a successful return value here indicates correct autn */ |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 186 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 187 | msgb_free(msg_rx); |
| 188 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 189 | fprintf(stderr, "- Expect the challenge response in msg_tx\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 190 | OSMO_ASSERT(msg_tx); |
Harald Welte | 5d547a4 | 2016-04-27 18:21:16 +0200 | [diff] [blame] | 191 | 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] | 192 | OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_CHALLENGE_RESULT); |
| 193 | OSMO_ASSERT(strcmp("e2d05b598c61d9ba", |
| 194 | osmo_hexdump_nospc(oap_tx.xres, sizeof(oap_tx.xres))) |
| 195 | == 0); |
| 196 | OSMO_ASSERT(state->state == OAP_SENT_CHALLENGE_RESULT); |
| 197 | msgb_free(msg_tx); |
| 198 | msg_tx = 0; |
| 199 | |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 200 | struct oap_client_state saved_state = _state; |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 201 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 202 | fprintf(stderr, "- Receive registration error for the first time.\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 203 | |
| 204 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 205 | oap_rx.message_type = OAP_MSGT_REGISTER_ERROR; |
| 206 | oap_rx.cause = GMM_CAUSE_PROTO_ERR_UNSPEC; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 207 | msg_rx = oap_client_encoded(&oap_rx); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 208 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 209 | OSMO_ASSERT(state->registration_failures == 0); |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 210 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 211 | OSMO_ASSERT(state->registration_failures == 1); |
| 212 | OSMO_ASSERT(msg_tx); |
Harald Welte | 5d547a4 | 2016-04-27 18:21:16 +0200 | [diff] [blame] | 213 | 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] | 214 | OSMO_ASSERT(oap_tx.message_type == OAP_MSGT_REGISTER_REQUEST); |
| 215 | OSMO_ASSERT(state->state == OAP_REQUESTED_CHALLENGE); |
| 216 | msgb_free(msg_tx); |
| 217 | msg_tx = 0; |
| 218 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 219 | fprintf(stderr, "- Receive registration error for the Nth time.\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 220 | state->registration_failures = 999; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 221 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == -11); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 222 | OSMO_ASSERT(!msg_tx); |
| 223 | OSMO_ASSERT(state->state == OAP_INITIALIZED); |
| 224 | msgb_free(msg_tx); |
| 225 | msg_tx = 0; |
| 226 | |
| 227 | msgb_free(msg_rx); |
| 228 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 229 | fprintf(stderr, "- Registration success\n"); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 230 | |
| 231 | _state = saved_state; |
| 232 | memset(&oap_rx, 0, sizeof(oap_rx)); |
| 233 | oap_rx.message_type = OAP_MSGT_REGISTER_RESULT; |
Neels Hofmeyr | 49012f1 | 2016-12-08 21:30:34 +0100 | [diff] [blame] | 234 | msg_rx = oap_client_encoded(&oap_rx); |
| 235 | OSMO_ASSERT(oap_client_handle(state, msg_rx, &msg_tx) == 0); |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 236 | OSMO_ASSERT(!msg_tx); |
| 237 | OSMO_ASSERT(state->state == OAP_REGISTERED); |
| 238 | msgb_free(msg_rx); |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 239 | } |
| 240 | |
Neels Hofmeyr | 73ed455 | 2016-12-09 00:01:56 +0100 | [diff] [blame] | 241 | static struct log_info_cat oap_client_test_categories[] = { |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 242 | }; |
| 243 | |
| 244 | static struct log_info info = { |
Neels Hofmeyr | 73ed455 | 2016-12-09 00:01:56 +0100 | [diff] [blame] | 245 | .cat = oap_client_test_categories, |
| 246 | .num_cat = ARRAY_SIZE(oap_client_test_categories), |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 247 | }; |
| 248 | |
| 249 | int main(int argc, char **argv) |
| 250 | { |
Neels Hofmeyr | 4c2d4ab | 2016-09-16 02:31:17 +0200 | [diff] [blame] | 251 | msgb_talloc_ctx_init(NULL, 0); |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 252 | osmo_init_logging(&info); |
| 253 | |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 254 | OSMO_ASSERT(osmo_stderr_target); |
Neels Hofmeyr | 73ed455 | 2016-12-09 00:01:56 +0100 | [diff] [blame] | 255 | log_set_use_color(osmo_stderr_target, 0); |
| 256 | log_set_print_timestamp(osmo_stderr_target, 0); |
| 257 | log_set_print_filename(osmo_stderr_target, 0); |
| 258 | log_set_print_category(osmo_stderr_target, 1); |
| 259 | log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); |
Neels Hofmeyr | 2e109f0 | 2016-12-08 23:35:20 +0100 | [diff] [blame] | 260 | |
Neels Hofmeyr | 89ef324 | 2015-10-12 11:57:36 +0200 | [diff] [blame] | 261 | test_oap_api(); |
Neels Hofmeyr | f06046b | 2015-10-12 11:57:35 +0200 | [diff] [blame] | 262 | printf("Done\n"); |
| 263 | |
| 264 | return 0; |
| 265 | } |
| 266 | |