RSPRO: Use ClientSlot in ConnectClientReq, ConfigClientReq

Change-Id: I33b44009eea338627b0ccbe69b9e4114e4fb85d8
This commit is contained in:
Harald Welte 2018-08-16 15:23:58 +02:00
parent 415e8f66ce
commit 371d026c6b
8 changed files with 30 additions and 23 deletions

View File

@ -151,7 +151,7 @@ ConnectBankRes ::= SEQUENCE {
ConnectClientReq ::= SEQUENCE { ConnectClientReq ::= SEQUENCE {
-- identity of the client that is connecting to the server/bankd -- identity of the client that is connecting to the server/bankd
identity ComponentIdentity, identity ComponentIdentity,
clientId ClientId OPTIONAL, -- old identity, if any clientSlot ClientSlot OPTIONAL, -- old identity, if any
... ...
} }
ConnectClientRes ::= SEQUENCE { ConnectClientRes ::= SEQUENCE {
@ -186,7 +186,7 @@ RemoveMappingRes ::= SEQUENCE {
-- SERVER->CLIENT: set configuration (client ID and BANK IP/Port) -- SERVER->CLIENT: set configuration (client ID and BANK IP/Port)
ConfigClientReq ::= SEQUENCE { ConfigClientReq ::= SEQUENCE {
-- server-allocated assignment of a client ID -- server-allocated assignment of a client ID
clientId ClientId, clientSlot ClientSlot,
-- bank to which the client shall connect -- bank to which the client shall connect
bankd IpPort, bankd IpPort,
... ...

View File

@ -11,7 +11,7 @@
#include <asn_application.h> #include <asn_application.h>
/* Including external dependencies */ /* Including external dependencies */
#include <osmocom/rspro/ClientId.h> #include <osmocom/rspro/ClientSlot.h>
#include <osmocom/rspro/IpPort.h> #include <osmocom/rspro/IpPort.h>
#include <constr_SEQUENCE.h> #include <constr_SEQUENCE.h>
@ -21,7 +21,7 @@ extern "C" {
/* ConfigClientReq */ /* ConfigClientReq */
typedef struct ConfigClientReq { typedef struct ConfigClientReq {
ClientId_t clientId; ClientSlot_t clientSlot;
IpPort_t bankd; IpPort_t bankd;
/* /*
* This type is extensible, * This type is extensible,

View File

@ -12,17 +12,19 @@
/* Including external dependencies */ /* Including external dependencies */
#include <osmocom/rspro/ComponentIdentity.h> #include <osmocom/rspro/ComponentIdentity.h>
#include <osmocom/rspro/ClientId.h>
#include <constr_SEQUENCE.h> #include <constr_SEQUENCE.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Forward declarations */
struct ClientSlot;
/* ConnectClientReq */ /* ConnectClientReq */
typedef struct ConnectClientReq { typedef struct ConnectClientReq {
ComponentIdentity_t identity; ComponentIdentity_t identity;
ClientId_t *clientId /* OPTIONAL */; struct ClientSlot *clientSlot /* OPTIONAL */;
/* /*
* This type is extensible, * This type is extensible,
* possible extensions are below. * possible extensions are below.
@ -39,5 +41,8 @@ extern asn_TYPE_descriptor_t asn_DEF_ConnectClientReq;
} }
#endif #endif
/* Referred external types */
#include <osmocom/rspro/ClientSlot.h>
#endif /* _ConnectClientReq_H_ */ #endif /* _ConnectClientReq_H_ */
#include <asn_internal.h> #include <asn_internal.h>

View File

@ -103,7 +103,7 @@ struct bankd_worker {
int fd; int fd;
struct sockaddr_storage peer_addr; struct sockaddr_storage peer_addr;
socklen_t peer_addr_len; socklen_t peer_addr_len;
unsigned int id; struct client_slot clslot;
} client; } client;
struct { struct {

View File

@ -215,11 +215,12 @@ static int worker_handle_connectClientReq(struct bankd_worker *worker, const Rsp
return -102; return -102;
} }
if (!pdu->msg.choice.connectClientReq.clientId) { if (!pdu->msg.choice.connectClientReq.clientSlot) {
LOGW(worker, "missing clientID, aborting\n"); LOGW(worker, "missing clientID, aborting\n");
return -103; 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); worker_set_state(worker, BW_ST_CONN_CLIENT);
/* FIXME: resolve mapping */ /* FIXME: resolve mapping */
@ -367,6 +368,7 @@ static void *worker_main(void *arg)
close(worker->client.fd); close(worker->client.fd);
memset(&worker->client.peer_addr, 0, sizeof(worker->client.peer_addr)); memset(&worker->client.peer_addr, 0, sizeof(worker->client.peer_addr));
worker->client.fd = -1; worker->client.fd = -1;
worker->client.clslot.client_id = worker->client.clslot.slot_nr = 0;
} }
pthread_cleanup_pop(1); pthread_cleanup_pop(1);

View File

@ -7,14 +7,14 @@
#include <osmocom/rspro/ConfigClientReq.h> #include <osmocom/rspro/ConfigClientReq.h>
static asn_TYPE_member_t asn_MBR_ConfigClientReq_1[] = { static asn_TYPE_member_t asn_MBR_ConfigClientReq_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, clientId), { ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, clientSlot),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0, 0,
&asn_DEF_ClientId, &asn_DEF_ClientSlot,
0, /* Defer constraints checking to the member type */ 0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */ 0, /* PER is not compiled, use -gen-PER */
0, 0,
"clientId" "clientSlot"
}, },
{ ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, bankd), { ATF_NOFLAGS, 0, offsetof(struct ConfigClientReq, bankd),
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), (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)) (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
}; };
static const asn_TYPE_tag2member_t asn_MAP_ConfigClientReq_tag2el_1[] = { 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)), 0, 0, 1 }, /* clientSlot */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, 0, 0 } /* bankd */ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* bankd */
}; };
static asn_SEQUENCE_specifics_t asn_SPC_ConfigClientReq_specs_1 = { static asn_SEQUENCE_specifics_t asn_SPC_ConfigClientReq_specs_1 = {
sizeof(struct ConfigClientReq), sizeof(struct ConfigClientReq),

View File

@ -16,22 +16,22 @@ static asn_TYPE_member_t asn_MBR_ConnectClientReq_1[] = {
0, 0,
"identity" "identity"
}, },
{ ATF_POINTER, 1, offsetof(struct ConnectClientReq, clientId), { ATF_POINTER, 1, offsetof(struct ConnectClientReq, clientSlot),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0, 0,
&asn_DEF_ClientId, &asn_DEF_ClientSlot,
0, /* Defer constraints checking to the member type */ 0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */ 0, /* PER is not compiled, use -gen-PER */
0, 0,
"clientId" "clientSlot"
}, },
}; };
static const ber_tlv_tag_t asn_DEF_ConnectClientReq_tags_1[] = { static const ber_tlv_tag_t asn_DEF_ConnectClientReq_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
}; };
static const asn_TYPE_tag2member_t asn_MAP_ConnectClientReq_tag2el_1[] = { 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, 1 }, /* identity */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* identity */ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* clientSlot */
}; };
static asn_SEQUENCE_specifics_t asn_SPC_ConnectClientReq_specs_1 = { static asn_SEQUENCE_specifics_t asn_SPC_ConnectClientReq_specs_1 = {
sizeof(struct ConnectClientReq), sizeof(struct ConnectClientReq),

View File

@ -127,13 +127,13 @@ RsproPDU_t *rspro_gen_CreateMappingReq(const ClientSlot_t *client, const BankSlo
return pdu; 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)); RsproPDU_t *pdu = CALLOC(1, sizeof(*pdu));
if (!pdu) if (!pdu)
return NULL; return NULL;
pdu->msg.present = RsproPDUchoice_PR_configClientReq; 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); fill_ip4_port(&pdu->msg.choice.configClientReq.bankd, ip, port);
return pdu; return pdu;