Harald Welte | 283c7fd | 2015-12-21 23:35:56 +0100 | [diff] [blame] | 1 | #include "sua_test_common.h" |
| 2 | |
| 3 | struct osmo_sua_user *g_user; |
| 4 | struct sua_link *g_link; |
| 5 | |
| 6 | static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link) |
| 7 | { |
| 8 | struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph; |
| 9 | struct osmo_prim_hdr *resp = NULL; |
| 10 | uint8_t payload[] = { 0xa1, 0xa2, 0xa3 }; |
| 11 | |
| 12 | printf("sccp_sap_up(%s)\n", osmo_sccp_prim_name(oph)); |
| 13 | |
| 14 | switch (OSMO_PRIM_HDR(oph)) { |
| 15 | case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_CONFIRM): |
| 16 | printf("N-CONNECT.ind(%u), issuing DATA.req\n", |
| 17 | prim->u.connect.conn_id); |
| 18 | resp = make_dt1_req(prim->u.connect.conn_id, payload, sizeof(payload)); |
| 19 | break; |
| 20 | } |
| 21 | |
| 22 | if (resp) |
Harald Welte | 8960704 | 2015-12-21 23:51:08 +0100 | [diff] [blame^] | 23 | osmo_sua_user_link_down(link, resp); |
Harald Welte | 283c7fd | 2015-12-21 23:35:56 +0100 | [diff] [blame] | 24 | |
| 25 | msgb_free(oph->msg); |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | |
| 30 | int main(int argc, char **argv) |
| 31 | { |
| 32 | void *ctx = talloc_named_const(NULL, 1, "root"); |
| 33 | int rc; |
| 34 | |
| 35 | osmo_sua_set_log_area(DSUA); |
| 36 | xua_set_log_area(DXUA); |
| 37 | |
| 38 | osmo_init_logging(&test_log_info); |
| 39 | |
| 40 | g_user = osmo_sua_user_create(ctx, sccp_sap_up); |
| 41 | |
Harald Welte | 8960704 | 2015-12-21 23:51:08 +0100 | [diff] [blame^] | 42 | rc = osmo_sua_client_connect(g_user, "127.0.0.1", 2342); |
Harald Welte | 283c7fd | 2015-12-21 23:35:56 +0100 | [diff] [blame] | 43 | if (rc < 0) { |
| 44 | exit(1); |
| 45 | } |
| 46 | |
Harald Welte | 8960704 | 2015-12-21 23:51:08 +0100 | [diff] [blame^] | 47 | g_link = osmo_sua_client_get_link(g_user); |
Harald Welte | 283c7fd | 2015-12-21 23:35:56 +0100 | [diff] [blame] | 48 | |
| 49 | int i = 8000; |
| 50 | |
| 51 | while (1) { |
| 52 | if (i < 8010) |
| 53 | tx_conn_req(g_link, i++); |
| 54 | //tx_unitdata(g_link); |
| 55 | osmo_select_main(0); |
| 56 | } |
| 57 | } |