PDA

View Full Version : composite id from string



frankson
05-28-2009, 12:18 PM
I would like to generate a composite id from a string given on stdin (or environment variable, file content), but not directly from the hardware of the current system.

Let's say, I want to build my composite id only from the ethernet id (HOSTID_ETHER), but I first want to check the ethernet ids given from the customer, e.g. if they come from a virtual machine. Since I cannot "decrypt" a composite id to get the ethernet id, I'd like to ask the customer to send me just the ethernet id.

So I have given the ethernet id as a text string, how to produce a composite id out of it?

I tried building a composite id from a vendor id, but this won't produce the same results. Given e.g. a ethernet id 00:11:22:33:44:55, I tried to supply "00:11:22:33:44:55" or "001122334455" as h->id.vendor in x_flexlm_gethostid(). Is there some api call like lc_hostid_from_string()?

Thanks in advance for any advice,

Frank

RobertDickau
05-28-2009, 03:50 PM
I haven't tried it, but as a test, does a composite-hostid-based-on-vendor-defined-hostid work if you mimic one of the string types, such as HOSTID_USER?

frankson
06-02-2009, 03:20 AM
First I tried


lc_new_job(...);
lc_hostid(lm_job, HOSTID_USER, buf);

which returns "USER=frank" for buf.


lc_init_simple_composite(lm_job, {HOSTID_USER}, 1);
lc_hostid(lm_job, HOSTID_COMPOSITE, buf);

yields "COMPOSITE=FF609E9F8F76". But


x_flexlm_newid();
lc_init_simple_composite(lm_job, {HOSTID_VENDOR}, 1);
lc_hostid(lm_job, HOSTID_COMPOSITE, buf);

/* using examples/vendor_hostid/vendor_hostid.c as template with */
h.get_vendor_id = x_flexlm_gethostid;
/* in x_flexlm_newid() and setting */
strncpy(h->id.vendor, "frank", MAX_HOSTID_LEN);
/* in x_flexlm_gethostid() */

will lead to "COMPOSITE=215938A349A8" :confused:

RobertDickau
06-02-2009, 09:53 AM
What is your custom keyword (the h.label or VENDEF_ID_TYPE string)? In any case, it might be that the hostid type is incorporated into the composite hostid hash, just as "USER=Something" and "HOSTNAME=Something" would presumably have different composites/hashes.

Depending on what you're doing, can you just always use your vendor-defined hostid type, where the validation side it gets its value from lc_hostid?

frankson
06-03-2009, 12:25 AM
... In any case, it might be that the hostid type is incorporated into the composite hostid hash, just as "USER=Something" and "HOSTNAME=Something" would presumably have different composites/hashes.

Depending on what you're doing, can you just always use your vendor-defined hostid type, where the validation side it gets its value from lc_hostid?

Yes, I see. Many thanks for this detailed answer!

Frank