encode actual hostname in RSPRO

The RSPRO ComponentIdentity includes a 'name' for each remsim component.

So far we always used "fixme-name" instead of something meaningful.
Let's use the hostname of the system instead.

Change-Id: I14925f16ae242dae89fa853a2fe31c5c1b32981d
changes/20/28020/4
Harald Welte 7 months ago
parent e9e505c7c5
commit eea631bff0
  1. 8
      src/bankd/bankd_main.c
  2. 8
      src/client/user_ifdhandler.c
  3. 6
      src/server/remsim_server.c

@ -59,6 +59,7 @@ static void handle_sig_mapadd(int sig);
__thread void *talloc_asn1_ctx;
struct bankd *g_bankd;
static void *g_tall_ctx;
static char g_hostname[256];
static void *worker_main(void *arg);
@ -91,7 +92,7 @@ static void bankd_init(struct bankd *bankd)
bankd->srvc.bankd.num_slots = 8;
bankd->comp_id.type = ComponentType_remsimBankd;
OSMO_STRLCPY_ARRAY(bankd->comp_id.name, "fixme-name");
OSMO_STRLCPY_ARRAY(bankd->comp_id.name, g_hostname);
OSMO_STRLCPY_ARRAY(bankd->comp_id.software, "remsim-bankd");
OSMO_STRLCPY_ARRAY(bankd->comp_id.sw_version, PACKAGE_VERSION);
/* FIXME: other members of app_comp_id */
@ -363,6 +364,9 @@ int main(int argc, char **argv)
g_bankd = talloc_zero(NULL, struct bankd);
OSMO_ASSERT(g_bankd);
if (gethostname(g_hostname, sizeof(g_hostname)) < 0)
OSMO_STRLCPY_ARRAY(g_hostname, "unknown");
bankd_init(g_bankd);
srvc = &g_bankd->srvc;
@ -370,7 +374,7 @@ int main(int argc, char **argv)
srvc->server_port = 9998;
srvc->handle_rx = bankd_srvc_handle_rx;
srvc->own_comp_id.type = ComponentType_remsimBankd;
OSMO_STRLCPY_ARRAY(srvc->own_comp_id.name, "fixme-name");
OSMO_STRLCPY_ARRAY(srvc->own_comp_id.name, g_hostname);
OSMO_STRLCPY_ARRAY(srvc->own_comp_id.software, "remsim-bankd");
OSMO_STRLCPY_ARRAY(srvc->own_comp_id.sw_version, PACKAGE_VERSION);

@ -125,7 +125,6 @@ struct client_thread {
/* configuration of client thread; passed in from IFD thread */
struct client_thread_cfg {
const char *name;
const char *server_host;
int server_port;
int client_id;
@ -367,8 +366,12 @@ static void *client_pthread_main(void *arg)
struct client_thread_cfg *cfg = arg;
struct client_config *ccfg;
struct client_thread *ct;
char hostname[256];
int rc;
if (gethostname(hostname, sizeof(hostname)) < 0)
OSMO_STRLCPY_ARRAY(hostname, "unknown");
osmo_select_init();
rc = osmo_ctx_init("client");
OSMO_ASSERT(rc == 0);
@ -387,7 +390,7 @@ static void *client_pthread_main(void *arg)
if (!talloc_asn1_ctx)
talloc_asn1_ctx= talloc_named_const(ct, 0, "asn1");
ct->bc = remsim_client_create(ct, cfg->name, "remsim_ifdhandler", ccfg);
ct->bc = remsim_client_create(ct, hostname, "remsim_ifdhandler", ccfg);
OSMO_ASSERT(ct->bc);
ct->bc->data = ct;
@ -560,7 +563,6 @@ RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName)
{
struct ifd_client *ic;
struct client_thread_cfg cfg = {
.name = "fixme-name",
.server_host = "127.0.0.1",
.server_port = -1,
.client_id = 0,

@ -80,9 +80,13 @@ static void handle_options(int argc, char **argv)
int main(int argc, char **argv)
{
char hostname[256];
void *talloc_rest_ctx;
int rc;
if (gethostname(hostname, sizeof(hostname)) < 0)
OSMO_STRLCPY_ARRAY(hostname, "unknown");
g_tall_ctx = talloc_named_const(NULL, 0, "global");
talloc_asn1_ctx = talloc_named_const(g_tall_ctx, 0, "asn1");
talloc_rest_ctx = talloc_named_const(g_tall_ctx, 0, "rest");
@ -106,7 +110,7 @@ int main(int argc, char **argv)
goto out_rspro;
g_rps->comp_id.type = ComponentType_remsimServer;
OSMO_STRLCPY_ARRAY(g_rps->comp_id.name, "fixme-name");
OSMO_STRLCPY_ARRAY(g_rps->comp_id.name, hostname);
OSMO_STRLCPY_ARRAY(g_rps->comp_id.software, "remsim-server");
OSMO_STRLCPY_ARRAY(g_rps->comp_id.sw_version, PACKAGE_VERSION);
/* FIXME: other members of app_comp_id */

Loading…
Cancel
Save