blob: b2c4e02334152d2ae4193f45c5859bb78a15474f [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
24#include "gsup_server.h"
25#include "gsup_router.h"
26
27#include <osmocom/core/logging.h>
28
29/* Send a msgb to a given address using routing */
30int osmo_gsup_addr_send(struct osmo_gsup_server *gs,
31 const uint8_t *addr, size_t addrlen,
32 struct msgb *msg)
33{
34 struct osmo_gsup_conn *conn;
35
36 conn = gsup_route_find(gs, addr, addrlen);
37 if (!conn) {
38 DEBUGP(DLGSUP, "Cannot find route for addr %s\n", addr);
39 msgb_free(msg);
40 return -ENODEV;
41 }
42
43 return osmo_gsup_conn_send(conn, msg);
44}
45