blob: 29aeaa5097ef62b54fb686e634171fbaee495c4f [file] [log] [blame]
Neels Hofmeyr9d307ec2018-05-04 16:06:32 +02001/* (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
Neels Hofmeyr2f758032019-11-20 00:37:07 +010024#include <osmocom/hlr/gsup_server.h>
25#include <osmocom/hlr/gsup_router.h>
Neels Hofmeyr9d307ec2018-05-04 16:06:32 +020026
27#include <osmocom/core/logging.h>
28
Oliver Smithf7d32512019-04-08 15:00:43 +020029/*! 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 Hofmeyr9d307ec2018-05-04 16:06:32 +020037int 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 Hofmeyr633fe292019-04-04 15:07:21 +020045 DEBUGP(DLGSUP, "Cannot find route for addr %s\n", osmo_quote_str((const char*)addr, addrlen));
Neels Hofmeyr9d307ec2018-05-04 16:06:32 +020046 msgb_free(msg);
47 return -ENODEV;
48 }
49
50 return osmo_gsup_conn_send(conn, msg);
51}
52