blob: 765cb517a94cd1fa944085bf87f406b9cb4553f8 [file] [log] [blame]
Harald Weltef1033cc2012-11-08 16:14:37 +01001/* SMPP 3.4 interface, SMSC-side implementation */
2/* (C) 2012 by Harald Welte <laforge@gnumonks.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19
20#include <stdio.h>
21#include <unistd.h>
22#include <string.h>
23#include <stdint.h>
24#include <errno.h>
25
26#include <sys/socket.h>
27#include <netinet/in.h>
28
29#include <smpp34.h>
30#include <smpp34_structs.h>
31#include <smpp34_params.h>
32
33#include <osmocom/core/utils.h>
34#include <osmocom/core/socket.h>
35#include <osmocom/core/msgb.h>
36#include <osmocom/core/logging.h>
37#include <osmocom/core/write_queue.h>
38#include <osmocom/core/talloc.h>
39
40#include "smpp_smsc.h"
41
42#include <openbsc/debug.h>
43
Harald Welte4dbcdad2012-11-08 22:12:45 +010044/*! \brief Ugly wrapper. libsmpp34 should do this itself! */
45#define SMPP34_UNPACK(rc, type, str, data, len) \
46 memset(str, 0, sizeof(*str)); \
47 rc = smpp34_unpack(type, str, data, len)
48
Harald Weltef1033cc2012-11-08 16:14:37 +010049enum emse_bind {
50 ESME_BIND_RX = 0x01,
51 ESME_BIND_TX = 0x02,
52};
53
Harald Weltee94db492012-11-08 20:11:05 +010054/*! \brief increaes the use/reference count */
55void smpp_esme_get(struct osmo_esme *esme)
56{
57 esme->use++;
58}
59
60static void esme_destroy(struct osmo_esme *esme)
61{
62 osmo_wqueue_clear(&esme->wqueue);
63 if (esme->wqueue.bfd.fd >= 0) {
64 osmo_fd_unregister(&esme->wqueue.bfd);
65 close(esme->wqueue.bfd.fd);
66 }
67 llist_del(&esme->list);
68 talloc_free(esme);
69}
70
71/*! \brief decrease the use/reference count, free if it is 0 */
72void smpp_esme_put(struct osmo_esme *esme)
73{
74 esme->use--;
75 if (esme->use <= 0)
76 esme_destroy(esme);
77}
78
Harald Welted4bdee72012-11-08 19:44:08 +010079static struct osmo_esme *
80esme_by_system_id(const struct smsc *smsc, char *system_id)
81{
82 struct osmo_esme *e;
83
84 llist_for_each_entry(e, &smsc->esme_list, list) {
85 if (!strcmp(e->system_id, system_id))
86 return e;
87 }
88 return NULL;
89}
Harald Weltef1033cc2012-11-08 16:14:37 +010090
91
Harald Weltee94db492012-11-08 20:11:05 +010092/*! \brief initialize the libsmpp34 data structure for a response */
Harald Weltef1033cc2012-11-08 16:14:37 +010093#define INIT_RESP(type, resp, req) { \
94 memset((resp), 0, sizeof(*(resp))); \
95 (resp)->command_length = 0; \
96 (resp)->command_id = type; \
97 (resp)->command_status = ESME_ROK; \
98 (resp)->sequence_number = (req)->sequence_number; \
99}
100
Harald Weltee94db492012-11-08 20:11:05 +0100101/*! \brief pack a libsmpp34 data strcutrure and send it to the ESME */
Harald Weltef1033cc2012-11-08 16:14:37 +0100102#define PACK_AND_SEND(esme, ptr) pack_and_send(esme, (ptr)->command_id, ptr)
103static int pack_and_send(struct osmo_esme *esme, uint32_t type, void *ptr)
104{
105 struct msgb *msg = msgb_alloc(4096, "SMPP_Tx");
106 int rc, rlen;
107 if (!msg)
108 return -ENOMEM;
109
110 rc = smpp34_pack(type, msg->tail, msgb_tailroom(msg), &rlen, ptr);
111 if (rc != 0) {
112 LOGP(DSMPP, LOGL_ERROR, "Error during smpp34_pack(): %s\n",
113 smpp34_strerror);
114 msgb_free(msg);
115 return -EINVAL;
116 }
117 msgb_put(msg, rlen);
118
119 return osmo_wqueue_enqueue(&esme->wqueue, msg);
120}
121
Harald Weltee94db492012-11-08 20:11:05 +0100122/*! \brief transmit a generic NACK to a remote ESME */
Harald Weltef1033cc2012-11-08 16:14:37 +0100123static int smpp_tx_gen_nack(struct osmo_esme *esme, uint32_t seq, uint32_t status)
124{
125 struct generic_nack_t nack;
126
127 nack.command_length = 0;
128 nack.command_id = GENERIC_NACK;
129 nack.sequence_number = seq;
130 nack.command_status = status;
131
132 return PACK_AND_SEND(esme, &nack);
133}
134
Harald Weltee94db492012-11-08 20:11:05 +0100135/*! \brief retrieve SMPP command ID from a msgb */
Harald Weltef1033cc2012-11-08 16:14:37 +0100136static inline uint32_t smpp_msgb_cmdid(struct msgb *msg)
137{
138 uint8_t *tmp = msgb_data(msg) + 4;
139 return ntohl(*(uint32_t *)tmp);
140}
141
Harald Weltee94db492012-11-08 20:11:05 +0100142/*! \brief retrieve SMPP sequence number from a msgb */
Harald Weltef1033cc2012-11-08 16:14:37 +0100143static inline uint32_t smpp_msgb_seq(struct msgb *msg)
144{
145 uint8_t *tmp = msgb_data(msg);
146 return ntohl(*(uint32_t *)tmp);
147}
148
Harald Weltee94db492012-11-08 20:11:05 +0100149/*! \brief handle an incoming SMPP generic NACK */
Harald Weltef1033cc2012-11-08 16:14:37 +0100150static int smpp_handle_gen_nack(struct osmo_esme *esme, struct msgb *msg)
151{
152 struct generic_nack_t nack;
153 char buf[SMALL_BUFF];
154 int rc;
155
Harald Welte4dbcdad2012-11-08 22:12:45 +0100156 SMPP34_UNPACK(rc, GENERIC_NACK, &nack, msgb_data(msg),
157 msgb_length(msg));
Harald Weltef1033cc2012-11-08 16:14:37 +0100158 if (rc < 0)
159 return rc;
160
161 LOGP(DSMPP, LOGL_ERROR, "%s: GENERIC NACK: %s\n", esme->system_id,
162 str_command_status(nack.command_status, buf));
163
164 return 0;
165}
166
Harald Weltee94db492012-11-08 20:11:05 +0100167/*! \brief handle an incoming SMPP BIND RECEIVER */
Harald Weltef1033cc2012-11-08 16:14:37 +0100168static int smpp_handle_bind_rx(struct osmo_esme *esme, struct msgb *msg)
169{
170 struct bind_receiver_t bind;
171 struct bind_receiver_resp_t bind_r;
172 int rc;
173
Harald Welte4dbcdad2012-11-08 22:12:45 +0100174 SMPP34_UNPACK(rc, BIND_RECEIVER, &bind, msgb_data(msg),
Harald Weltef1033cc2012-11-08 16:14:37 +0100175 msgb_length(msg));
176 if (rc < 0)
177 return rc;
178
179 INIT_RESP(BIND_TRANSMITTER_RESP, &bind_r, &bind);
180
181 LOGP(DSMPP, LOGL_INFO, "%s: BIND Rx from (Version %02x)\n",
182 bind.system_id, bind.interface_version);
183
184 if (bind.interface_version != SMPP_VERSION) {
185 bind_r.command_status = ESME_RSYSERR;
186 goto err;
187 }
188
189 if (esme->bind_flags) {
190 bind_r.command_status = ESME_RALYBND;
191 goto err;
192 }
193
194 esme->smpp_version = bind.interface_version;
195 snprintf(esme->system_id, sizeof(esme->system_id), "%s",
196 bind.system_id);
197 esme->bind_flags = ESME_BIND_RX;
198
199 /* FIXME */
200err:
201 return 0;
202}
203
Harald Weltee94db492012-11-08 20:11:05 +0100204/*! \brief handle an incoming SMPP BIND TRANSMITTER */
Harald Weltef1033cc2012-11-08 16:14:37 +0100205static int smpp_handle_bind_tx(struct osmo_esme *esme, struct msgb *msg)
206{
207 struct bind_transmitter_t bind;
208 struct bind_transmitter_resp_t bind_r;
209 struct tlv_t tlv;
210 int rc;
211
Harald Welte4dbcdad2012-11-08 22:12:45 +0100212 SMPP34_UNPACK(rc, BIND_TRANSMITTER, &bind, msgb_data(msg),
Harald Weltef1033cc2012-11-08 16:14:37 +0100213 msgb_length(msg));
214 if (rc < 0) {
215 printf("error during unpack: %s\n", smpp34_strerror);
216 return rc;
217 }
218
219 INIT_RESP(BIND_TRANSMITTER_RESP, &bind_r, &bind);
220
221 LOGP(DSMPP, LOGL_INFO, "%s: BIND Tx (Version %02x)\n",
222 bind.system_id, bind.interface_version);
223
224 if (bind.interface_version != SMPP_VERSION) {
225 bind_r.command_status = ESME_RSYSERR;
226 goto err;
227 }
228
229 if (esme->bind_flags) {
230 bind_r.command_status = ESME_RALYBND;
231 goto err;
232 }
233
234 esme->smpp_version = bind.interface_version;
235 snprintf(esme->system_id, sizeof(esme->system_id), "%s", bind.system_id);
236 esme->bind_flags = ESME_BIND_TX;
237
238 /* build response */
239 snprintf((char *)bind_r.system_id, sizeof(bind_r.system_id), "%s",
240 esme->smsc->system_id);
241
242 /* add interface version TLV */
243 tlv.tag = TLVID_sc_interface_version;
244 tlv.length = sizeof(uint8_t);
245 tlv.value.val16 = esme->smpp_version;
246 build_tlv(&bind_r.tlv, &tlv);
247
248err:
249 return PACK_AND_SEND(esme, &bind_r);
250}
251
Harald Weltee94db492012-11-08 20:11:05 +0100252/*! \brief handle an incoming SMPP BIND TRANSCEIVER */
Harald Weltef1033cc2012-11-08 16:14:37 +0100253static int smpp_handle_bind_trx(struct osmo_esme *esme, struct msgb *msg)
254{
255 struct bind_transceiver_t bind;
256 struct bind_transceiver_resp_t bind_r;
257 int rc;
258
Harald Welte4dbcdad2012-11-08 22:12:45 +0100259 SMPP34_UNPACK(rc, BIND_TRANSCEIVER, &bind, msgb_data(msg),
Harald Weltef1033cc2012-11-08 16:14:37 +0100260 msgb_length(msg));
261 if (rc < 0)
262 return rc;
263
264 INIT_RESP(BIND_TRANSMITTER_RESP, &bind_r, &bind);
265
266 LOGP(DSMPP, LOGL_INFO, "%s: BIND Trx (Version %02x)\n",
267 bind.system_id, bind.interface_version);
268
269 if (bind.interface_version != SMPP_VERSION) {
270 bind_r.command_status = ESME_RSYSERR;
271 goto err;
272 }
273
274 if (esme->bind_flags) {
275 bind_r.command_status = ESME_RALYBND;
276 goto err;
277 }
278
279 esme->smpp_version = bind.interface_version;
280 snprintf(esme->system_id, sizeof(esme->system_id), "%s", bind.system_id);
281 esme->bind_flags |= ESME_BIND_TX | ESME_BIND_RX;
282
283 /* FIXME */
284err:
285 return 0;
286}
287
Harald Weltee94db492012-11-08 20:11:05 +0100288/*! \brief handle an incoming SMPP UNBIND */
Harald Weltef1033cc2012-11-08 16:14:37 +0100289static int smpp_handle_unbind(struct osmo_esme *esme, struct msgb *msg)
290{
291 struct unbind_t unbind;
292 struct unbind_resp_t unbind_r;
293 int rc;
294
Harald Welte4dbcdad2012-11-08 22:12:45 +0100295 SMPP34_UNPACK(rc, UNBIND, &unbind, msgb_data(msg),
Harald Weltef1033cc2012-11-08 16:14:37 +0100296 msgb_length(msg));
297 if (rc < 0)
298 return rc;
299
300 INIT_RESP(UNBIND_RESP, &unbind_r, &unbind);
301
302 LOGP(DSMPP, LOGL_INFO, "%s: UNBIND\n", esme->system_id);
303
304 if (esme->bind_flags == 0) {
305 unbind_r.command_status = ESME_RINVBNDSTS;
306 goto err;
307 }
308
309 esme->bind_flags = 0;
310err:
311 return PACK_AND_SEND(esme, &unbind_r);
312}
313
Harald Weltee94db492012-11-08 20:11:05 +0100314/*! \brief handle an incoming SMPP ENQUIRE LINK */
Harald Weltef1033cc2012-11-08 16:14:37 +0100315static int smpp_handle_enq_link(struct osmo_esme *esme, struct msgb *msg)
316{
317 struct enquire_link_t enq;
318 struct enquire_link_resp_t enq_r;
319 int rc;
320
Harald Welte4dbcdad2012-11-08 22:12:45 +0100321 SMPP34_UNPACK(rc, ENQUIRE_LINK, &enq, msgb_data(msg),
Harald Weltef1033cc2012-11-08 16:14:37 +0100322 msgb_length(msg));
323 if (rc < 0)
324 return rc;
325
326 LOGP(DSMPP, LOGL_DEBUG, "%s: Enquire Link\n", esme->system_id);
327
328 INIT_RESP(ENQUIRE_LINK_RESP, &enq_r, &enq);
329
330 return PACK_AND_SEND(esme, &enq_r);
331}
332
Harald Weltee94db492012-11-08 20:11:05 +0100333/*! \brief send a SUBMIT-SM RESPONSE to a remote ESME */
Harald Welted4bdee72012-11-08 19:44:08 +0100334int smpp_tx_submit_r(struct osmo_esme *esme, uint32_t sequence_nr,
335 uint32_t command_status, char *msg_id)
336{
337 struct submit_sm_resp_t submit_r;
338
339 memset(&submit_r, 0, sizeof(submit_r));
340 submit_r.command_length = 0;
341 submit_r.command_id = SUBMIT_SM_RESP;
342 submit_r.command_status = command_status;
343 submit_r.sequence_number= sequence_nr;
344 snprintf(submit_r.message_id, sizeof(submit_r.message_id), "%s", msg_id);
345
346 return PACK_AND_SEND(esme, &submit_r);
347}
348
Harald Weltee94db492012-11-08 20:11:05 +0100349/*! \brief handle an incoming SMPP SUBMIT-SM */
Harald Weltef1033cc2012-11-08 16:14:37 +0100350static int smpp_handle_submit(struct osmo_esme *esme, struct msgb *msg)
351{
352 struct submit_sm_t submit;
353 struct submit_sm_resp_t submit_r;
354 int rc;
355
Harald Welte4dbcdad2012-11-08 22:12:45 +0100356 memset(&submit, 0, sizeof(submit));
357 SMPP34_UNPACK(rc, SUBMIT_SM, &submit, msgb_data(msg),
Harald Weltef1033cc2012-11-08 16:14:37 +0100358 msgb_length(msg));
359 if (rc < 0)
360 return rc;
361
362 INIT_RESP(SUBMIT_SM_RESP, &submit_r, &submit);
363
364 if (!(esme->bind_flags & ESME_BIND_TX)) {
365 submit_r.command_status = ESME_RINVBNDSTS;
366 return PACK_AND_SEND(esme, &submit_r);
367 }
368
369 LOGP(DSMPP, LOGL_INFO, "%s: SUBMIT-SM(%s)\n", esme->system_id,
370 submit.service_type);
371
372 INIT_RESP(SUBMIT_SM_RESP, &submit_r, &submit);
373
374 rc = handle_smpp_submit(esme, &submit, &submit_r);
375 if (rc == 0)
376 return PACK_AND_SEND(esme, &submit_r);
377
378 return rc;
379}
380
Harald Weltee94db492012-11-08 20:11:05 +0100381/*! \brief one complete SMPP PDU from the ESME has been received */
Harald Weltef1033cc2012-11-08 16:14:37 +0100382static int smpp_pdu_rx(struct osmo_esme *esme, struct msgb *msg)
383{
384 uint32_t cmd_id = smpp_msgb_cmdid(msg);
385 int rc = 0;
386
387 LOGP(DSMPP, LOGL_DEBUG, "%s: smpp_pdu_rx(%s)\n", esme->system_id,
388 osmo_hexdump(msgb_data(msg), msgb_length(msg)));
389
390 switch (cmd_id) {
391 case GENERIC_NACK:
392 rc = smpp_handle_gen_nack(esme, msg);
393 break;
394 case BIND_RECEIVER:
395 rc = smpp_handle_bind_rx(esme, msg);
396 break;
397 case BIND_TRANSMITTER:
398 rc = smpp_handle_bind_tx(esme, msg);
399 break;
400 case BIND_TRANSCEIVER:
401 rc = smpp_handle_bind_trx(esme, msg);
402 break;
403 case UNBIND:
404 rc = smpp_handle_unbind(esme, msg);
405 break;
406 case ENQUIRE_LINK:
407 rc = smpp_handle_enq_link(esme, msg);
408 break;
409 case SUBMIT_SM:
410 rc = smpp_handle_submit(esme, msg);
411 break;
412 case DELIVER_SM:
413 break;
414 case DATA_SM:
415 break;
416 case CANCEL_SM:
417 case QUERY_SM:
418 case REPLACE_SM:
419 case SUBMIT_MULTI:
420 LOGP(DSMPP, LOGL_NOTICE, "%s: Unimplemented PDU Commmand "
421 "0x%08x\n", esme->system_id, cmd_id);
422 break;
423 default:
424 LOGP(DSMPP, LOGL_ERROR, "%s: Unknown PDU Command 0x%08x\n",
425 esme->system_id, cmd_id);
426 rc = smpp_tx_gen_nack(esme, smpp_msgb_seq(msg), ESME_RINVCMDID);
427 break;
428 }
429
430 return rc;
431}
432
Harald Weltee94db492012-11-08 20:11:05 +0100433/* !\brief call-back when per-ESME TCP socket has some data to be read */
Harald Weltef1033cc2012-11-08 16:14:37 +0100434static int esme_link_read_cb(struct osmo_fd *ofd)
435{
436 struct osmo_esme *esme = ofd->data;
437 uint32_t len;
438 uint8_t *lenptr = (uint8_t *) &len;
439 uint8_t *cur;
440 struct msgb *msg;
441 int rdlen;
442 int rc;
443
444 switch (esme->read_state) {
445 case READ_ST_IN_LEN:
446 rdlen = sizeof(uint32_t) - esme->read_idx;
447 rc = read(ofd->fd, lenptr + esme->read_idx, rdlen);
448 if (rc < 0) {
449 LOGP(DSMPP, LOGL_ERROR, "read returned %d\n", rc);
450 } else if (rc == 0) {
451 goto dead_socket;
452 } else
453 esme->read_idx += rc;
454 if (esme->read_idx >= sizeof(uint32_t)) {
455 esme->read_len = ntohl(len);
456 msg = msgb_alloc(esme->read_len, "SMPP Rx");
457 if (!msg)
458 return -ENOMEM;
459 esme->read_msg = msg;
460 cur = msgb_put(msg, sizeof(uint32_t));
461 memcpy(cur, lenptr, sizeof(uint32_t));
462 esme->read_state = READ_ST_IN_MSG;
463 esme->read_idx = sizeof(uint32_t);
464 }
465 break;
466 case READ_ST_IN_MSG:
467 msg = esme->read_msg;
468 rdlen = esme->read_len - esme->read_idx;
469 rc = read(ofd->fd, msg->tail, OSMO_MIN(rdlen, msgb_tailroom(msg)));
470 if (rc < 0) {
471 LOGP(DSMPP, LOGL_ERROR, "read returned %d\n", rc);
472 } else if (rc == 0) {
473 goto dead_socket;
474 } else {
475 esme->read_idx += rc;
476 msgb_put(msg, rc);
477 }
478
479 if (esme->read_idx >= esme->read_len) {
480 rc = smpp_pdu_rx(esme, esme->read_msg);
481 esme->read_msg = NULL;
482 esme->read_idx = 0;
483 esme->read_len = 0;
484 esme->read_state = READ_ST_IN_LEN;
485 }
486 break;
487 }
488
489 return 0;
490dead_socket:
491 msgb_free(esme->read_msg);
Harald Weltee94db492012-11-08 20:11:05 +0100492 osmo_fd_unregister(&esme->wqueue.bfd);
493 close(esme->wqueue.bfd.fd);
494 esme->wqueue.bfd.fd = -1;
495 smpp_esme_put(esme);
Harald Weltef1033cc2012-11-08 16:14:37 +0100496
497 return 0;
498}
499
500/* call-back of write queue once it wishes to write a message to the socket */
501static void esme_link_write_cb(struct osmo_fd *ofd, struct msgb *msg)
502{
503 struct osmo_esme *esme = ofd->data;
504 int rc;
505
506 rc = write(ofd->fd, msgb_data(msg), msgb_length(msg));
507 if (rc == 0) {
Harald Weltee94db492012-11-08 20:11:05 +0100508 osmo_fd_unregister(&esme->wqueue.bfd);
509 close(esme->wqueue.bfd.fd);
510 esme->wqueue.bfd.fd = -1;
511 smpp_esme_put(esme);
Harald Weltef1033cc2012-11-08 16:14:37 +0100512 } else if (rc < msgb_length(msg)) {
513 LOGP(DSMPP, LOGL_ERROR, "%s: Short write\n", esme->system_id);
514 return;
515 }
516}
517
518/* callback for already-accepted new TCP socket */
519static int link_accept_cb(struct smsc *smsc, int fd,
520 struct sockaddr_storage *s, socklen_t s_len)
521{
522 struct osmo_esme *esme = talloc_zero(smsc, struct osmo_esme);
523 if (!esme)
524 return -ENOMEM;
525
Harald Weltee94db492012-11-08 20:11:05 +0100526 smpp_esme_get(esme);
Harald Weltef1033cc2012-11-08 16:14:37 +0100527 esme->smsc = smsc;
528 osmo_wqueue_init(&esme->wqueue, 10);
529 esme->wqueue.bfd.fd = fd;
530 esme->wqueue.bfd.data = esme;
531 esme->wqueue.bfd.when = BSC_FD_READ;
532 osmo_fd_register(&esme->wqueue.bfd);
533
534 esme->wqueue.read_cb = esme_link_read_cb;
535 esme->wqueue.write_cb = esme_link_write_cb;
536
537 esme->sa_len = OSMO_MIN(sizeof(esme->sa), s_len);
538 memcpy(&esme->sa, s, esme->sa_len);
539
540 llist_add_tail(&esme->list, &smsc->esme_list);
541
542 return 0;
543}
544
545/* callback of listening TCP socket */
546static int smsc_fd_cb(struct osmo_fd *ofd, unsigned int what)
547{
548 int rc;
549 struct sockaddr_storage sa;
550 socklen_t sa_len = sizeof(sa);
551
552 rc = accept(ofd->fd, (struct sockaddr *)&sa, &sa_len);
553 if (rc < 0) {
554 LOGP(DSMPP, LOGL_ERROR, "Accept returns %d (%s)\n",
555 rc, strerror(errno));
556 return rc;
557 }
558 return link_accept_cb(ofd->data, rc, &sa, sa_len);
559}
560
Harald Weltee94db492012-11-08 20:11:05 +0100561/*! \brief Initialize the SMSC-side SMPP implementation */
Harald Weltef1033cc2012-11-08 16:14:37 +0100562int smpp_smsc_init(struct smsc *smsc, uint16_t port)
563{
564 int rc;
565
566 INIT_LLIST_HEAD(&smsc->esme_list);
567 smsc->listen_ofd.data = smsc;
568 smsc->listen_ofd.cb = smsc_fd_cb;
569 rc = osmo_sock_init_ofd(&smsc->listen_ofd, AF_UNSPEC, SOCK_STREAM,
570 IPPROTO_TCP, NULL, port, OSMO_SOCK_F_BIND);
571
572 return rc;
573}