aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-08-16 15:23:58 +0200
committerHarald Welte <laforge@gnumonks.org>2018-08-16 15:30:41 +0200
commit371d026c6b57de141974a82aa66d57de63092992 (patch)
treed6d7d9f10cc7ab66f7b180bf3600d1be04ee77ef
parent415e8f66ce12d6d0868559bed384a7e8c202be9b (diff)
RSPRO: Use ClientSlot in ConnectClientReq, ConfigClientReq
-rw-r--r--asn1/RSPRO.asn4
-rw-r--r--include/osmocom/rspro/ConfigClientReq.h4
-rw-r--r--include/osmocom/rspro/ConnectClientReq.h9
-rw-r--r--src/bankd.h2
-rw-r--r--src/bankd_main.c6
-rw-r--r--src/rspro/ConfigClientReq.c12
-rw-r--r--src/rspro/ConnectClientReq.c12
-rw-r--r--src/rspro_util.c4
8 files changed, 30 insertions, 23 deletions
diff --git a/asn1/RSPRO.asn b/asn1/RSPRO.asn
index 75a36c7..8772ee7 100644
--- a/asn1/RSPRO.asn
+++ b/asn1/RSPRO.asn
@@ -151,7 +151,7 @@ ConnectBankRes ::= SEQUENCE {
ConnectClientReq ::= SEQUENCE {
-- identity of the client that is connecting to the server/bankd
identity ComponentIdentity,
- clientId ClientId OPTIONAL, -- old identity, if any
+ clientSlot ClientSlot OPTIONAL, -- old identity, if any
...
}
ConnectClientRes ::= SEQUENCE {
@@ -186,7 +186,7 @@ RemoveMappingRes ::= SEQUENCE {
-- SERVER->CLIENT: set configuration (client ID and BANK IP/Port)
ConfigClientReq ::= SEQUENCE {
-- server-allocated assignment of a client ID
- clientId ClientId,
+ clientSlot ClientSlot,
-- bank to which the client shall connect
bankd IpPort,
...
diff --git a/include/osmocom/rspro/ConfigClientReq.h b/include/osmocom/rspro/ConfigClientReq.h
index 670fb68..73a6768 100644
--- a/include/osmocom/rspro/ConfigClientReq.h
+++ b/include/osmocom/rspro/ConfigClientReq.h
@@ -11,7 +11,7 @@
#include <asn_application.h>
/* Including external dependencies */
-#include <osmocom/rspro/ClientId.h>
+#include <osmocom/rspro/ClientSlot.h>
#include <osmocom/rspro/IpPort.h>
#include <constr_SEQUENCE.h>
@@ -21,7 +21,7 @@ extern "C" {
/* ConfigClientReq */
typedef struct ConfigClientReq {
- ClientId_t clientId;
+ ClientSlot_t clientSlot;
IpPort_t bankd;
/*
* This type is extensible,
diff --git a/include/osmocom/rspro/ConnectClientReq.h b/include/osmocom/rspro/ConnectClientReq.h
index 46c2d0e..2087d1c 100644
--- a/include/osmocom/rspro/ConnectClientReq.h
+++ b/include/osmocom/rspro/ConnectClientReq.h
@@ -12,17 +12,19 @@
/* Including external dependencies */
#include <osmocom/rspro/ComponentIdentity.h>
-#include <osmocom/rspro/ClientId.h>
#include <constr_SEQUENCE.h>
#ifdef __cplusplus
extern "C" {
#endif
+/* Forward declarations */
+struct ClientSlot;
+
/* ConnectClientReq */
typedef struct ConnectClientReq {
ComponentIdentity_t identity;
- ClientId_t *clientId /* OPTIONAL */;
+ struct ClientSlot *clientSlot /* OPTIONAL */;
/*
* This type is extensible,
* possible extensions are below.
@@ -39,5 +41,8 @@ extern asn_TYPE_descriptor_t asn_DEF_ConnectClientReq;
}
#endif
+/* Referred external types */
+#include <osmocom/rspro/ClientSlot.h>
+
#endif /* _ConnectClientReq_H_ */
#include <asn_internal.h>
diff --git a/src/bankd.h b/src/bankd.h
index e97b702..9d17389 100644
--- a/src/bankd.h
+++ b/src/bankd.h
@@ -103,7 +103,7 @@ struct bankd_worker {
int fd;
struct sockaddr_storage peer_addr;
socklen_t peer_addr_len;
- unsigned int id;
+ struct client_slot clslot;
} client;
struct {
diff --git a/src/bankd_main.c b/src/bankd_main.c
index cbe33c1..76a8d6c 100644
--- a/src/bankd_main.c
+++ b/src/bankd_main.c
@@ -215,11 +215,12 @@ static int worker_handle_connectClientReq(struct bankd_worker *worker, const Rsp
return -102;
}
- if (!pdu->msg.choice.connectClientReq.clientId) {
+ if (!pdu->msg.choice.connectClientReq.clientSlot) {
LOGW(worker, "missing clientID, aborting\n");
return -103;
}
- worker->client.id = *pdu->msg.choice.connectClientReq.clientId;
+ worker->client.clslot.client_id = pdu->msg.choice.connectClientReq.clientSlot->clientId;
+ worker->client.clslot.slot_nr = pdu->msg.choice.connectClientReq.clientSlot->slotNr;
worker_set_state(worker, BW_ST_CONN_CLIENT);
/* FIXME: resolve mapping */
@@ -367,6 +368,7 @@ static void *worker_main(void *arg)
close(worker->client.fd);
memset(&worker->client.peer_addr, 0, sizeof(worker->client.peer_addr));
worker->client.fd = -1;
+ worker->client.clslot.client_id = worker->client.clslot.slot_nr = 0;
}
pthread_cleanup_pop(1);
diff --git a/src/rspro/ConfigClientReq.c b/src/rspro/ConfigClientReq.c
index 1221b4a..586ac41 100644
--- a/src/rspro/ConfigClientReq.c
+++ b/src/rspro/ConfigClientReq.c
@@ -7,14 +7,14 @@
#include <osmocom/rspro/ConfigClientReq.h>
static asn_TYPE_member_t asn_MBR_ConfigClientReq_1[] = {
- { ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, clientId),
- (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
+ { ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, clientSlot),
+ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
- &asn_DEF_ClientId,
+ &asn_DEF_ClientSlot,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
- "clientId"
+ "clientSlot"
},
{ ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, bankd),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
@@ -30,8 +30,8 @@ static const ber_tlv_tag_t asn_DEF_ConfigClientReq_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_ConfigClientReq_tag2el_1[] = {
- { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* clientId */
- { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, 0, 0 } /* bankd */
+ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 1 }, /* clientSlot */
+ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* bankd */
};
static asn_SEQUENCE_specifics_t asn_SPC_ConfigClientReq_specs_1 = {
sizeof(struct ConfigClientReq),
diff --git a/src/rspro/ConnectClientReq.c b/src/rspro/ConnectClientReq.c
index 7b83b19..16cc091 100644
--- a/src/rspro/ConnectClientReq.c
+++ b/src/rspro/ConnectClientReq.c
@@ -16,22 +16,22 @@ static asn_TYPE_member_t asn_MBR_ConnectClientReq_1[] = {
0,
"identity"
},
- { ATF_POINTER, 1, offsetof(struct ConnectClientReq, clientId),
- (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
+ { ATF_POINTER, 1, offsetof(struct ConnectClientReq, clientSlot),
+ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
- &asn_DEF_ClientId,
+ &asn_DEF_ClientSlot,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
- "clientId"
+ "clientSlot"
},
};
static const ber_tlv_tag_t asn_DEF_ConnectClientReq_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_ConnectClientReq_tag2el_1[] = {
- { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* clientId */
- { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* identity */
+ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 1 }, /* identity */
+ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* clientSlot */
};
static asn_SEQUENCE_specifics_t asn_SPC_ConnectClientReq_specs_1 = {
sizeof(struct ConnectClientReq),
diff --git a/src/rspro_util.c b/src/rspro_util.c
index 7ff93c3..9f8c3d5 100644
--- a/src/rspro_util.c
+++ b/src/rspro_util.c
@@ -127,13 +127,13 @@ RsproPDU_t *rspro_gen_CreateMappingReq(const ClientSlot_t *client, const BankSlo
return pdu;
}
-RsproPDU_t *rspro_gen_ConfigClientReq(uint16_t client_id, uint32_t ip, uint16_t port)
+RsproPDU_t *rspro_gen_ConfigClientReq(const ClientSlot_t *client, uint32_t ip, uint16_t port)
{
RsproPDU_t *pdu = CALLOC(1, sizeof(*pdu));
if (!pdu)
return NULL;
pdu->msg.present = RsproPDUchoice_PR_configClientReq;
- pdu->msg.choice.configClientReq.clientId = client_id;
+ pdu->msg.choice.configClientReq.clientSlot = *client;
fill_ip4_port(&pdu->msg.choice.configClientReq.bankd, ip, port);
return pdu;