Neels Hofmeyr | 9d307ec | 2018-05-04 16:06:32 +0200 | [diff] [blame] | 1 | /* (C) 2018 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 2 | * |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Affero General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | /* This is kept separate to be able to override the actual sending functions from unit tests. */ |
| 21 | |
| 22 | #include <errno.h> |
| 23 | |
| 24 | #include "gsup_server.h" |
| 25 | #include "gsup_router.h" |
| 26 | |
| 27 | #include <osmocom/core/logging.h> |
| 28 | |
Oliver Smith | f7d3251 | 2019-04-08 15:00:43 +0200 | [diff] [blame] | 29 | /*! Send a msgb to a given address using routing. |
| 30 | * \param[in] gs gsup server |
| 31 | * \param[in] addr IPA name of the client (SGSN, MSC/VLR). Although this is passed like a blob, together with the |
| 32 | * length, it must be nul-terminated! This is for legacy reasons, see the discussion here: |
| 33 | * https://gerrit.osmocom.org/#/c/osmo-hlr/+/13048/ |
| 34 | * \param[in] addrlen length of addr, *including the nul-byte* (strlen(addr) + 1). |
| 35 | * \param[in] msg message buffer |
| 36 | */ |
Neels Hofmeyr | 9d307ec | 2018-05-04 16:06:32 +0200 | [diff] [blame] | 37 | int osmo_gsup_addr_send(struct osmo_gsup_server *gs, |
| 38 | const uint8_t *addr, size_t addrlen, |
| 39 | struct msgb *msg) |
| 40 | { |
| 41 | struct osmo_gsup_conn *conn; |
| 42 | |
| 43 | conn = gsup_route_find(gs, addr, addrlen); |
| 44 | if (!conn) { |
Neels Hofmeyr | 633fe29 | 2019-04-04 15:07:21 +0200 | [diff] [blame] | 45 | DEBUGP(DLGSUP, "Cannot find route for addr %s\n", osmo_quote_str((const char*)addr, addrlen)); |
Neels Hofmeyr | 9d307ec | 2018-05-04 16:06:32 +0200 | [diff] [blame] | 46 | msgb_free(msg); |
| 47 | return -ENODEV; |
| 48 | } |
| 49 | |
| 50 | return osmo_gsup_conn_send(conn, msg); |
| 51 | } |
| 52 | |