cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to implement multiple vendor-defined hostid's

How to implement multiple vendor-defined hostid's

Summary

How can you implement multiple VDH's? Either across multiple features in the same license file, or multiple VDH's in the same feature line?

Question

How can you implement multiple VDH's? Either across multiple features in the same license file, or multiple VDH's in the same feature line?

Answer

The parts of a licensing system that need to know about a Vendor-defined Hostid (VDH) are:
1. lmcrypt (and the VCG if using FlexNet Operations, which is kind of the same thing), to sign licenses including a VDH.
2. vendor daemon (if using served licenses), to validate a served license's VDH.
3. FLEXenabled application, to validate a VDH.

To allow for multiple VDH Support, the following need to be considered:
1. Supporting multiple VDH types in one FLEXenabled app
2. Defining a composite hostid that includes a VDH

A central source file for VDH support is vendor_hostid.c, which defines the VDH keyword and current VDH value in HOSTID=keyword=value

The two main functions to implement are by default called
x_flexlm_newid, which defines the types; and
x_flexlm_gethostid, which gets the current hostid value

The aim is to be able to check out licenses that look like this:

INCREMENT V1 demo 1.0 1-jan-2015 uncounted \
HOSTID=SOMETHING=SpecialValue SIGN=0
INCREMENT V1 demo 1.0 1-jan-2015 uncounted \
HOSTID=SOMETHINGELSE=OtherValue SIGN=0

The function that computes the current VDH value has this signature...

HOSTID * x_flexlm_gethostid(short idtype)

...so the trick is to compute different values based on the idtype argument.

Each hostid (whether built-in or custom) has a unique numeric type, and that function gets passed the type under consideration; custom types start with HOSTID_VENDOR (1000).

There's no reason you can't use two different functions for that matter, instead of the one x_flexlm_gethostid call that tests idtype.

The other function, x_flexlm_newid, needs to be referenced in the lmcrypt, vendor daemon, and lmflex-like source files, and the vendor_hostid object file needs to be linked in, but nothing different about that compared to working with a single VDH.

What is different (when setting up multiple VDH's versus only one) is setting up a linked list of hostid types. Setting up the linked list (using the next member of the LM_VENDOR_HOSTID structure) apparently requires this at the top of vendor_hostid.c

#define LM_INTERNAL

After building everything to use the vendor_hostid code or library, lmcrypt can sign a license that uses either type of VDH, and lmflex can check out a license that uses either type.


Additional Information

...PSEUDOCODE FOR vendor_hostid.c...

#define VENDEF_ID_TYPE HOSTID_VENDOR + 1
#define VENDEF_ID_TYPE2 HOSTID_VENDOR + 2

#define VENDEF_ID_LABEL "KEYWORD1"
#define VENDEF_ID_LABEL2 "KEYWORD2"

HOSTID * x_flexlm_gethostid(short idtype)
{
HOSTID *h = l_new_hostid( );

if (idtype == VENDEF_ID_TYPE)
{
h->type = VENDEF_ID_TYPE;
// compute and return value for keyword 1
}

if (idtype == VENDEF_ID_TYPE2)
{
h->type = VENDEF_ID_TYPE2;
// compute and return the value for keyword 2
}
return ((HOSTID *)NULL);
}



...EXAMPLE CODE for lmflex.c...

if (lc_new_job...)
{
...
}

x_flexlm_newid( ); // for VDH

// printf("Enter \"f1\" to demo floating...



...EXAMPLE CODE for lmcrypt.c...

code = &site_code;
strcpy(primVendName, VENDOR_HAME);
if (lc_init...)
{
...
}

x_flexlm_newid( ); // for VHD

iofiles = (char **)safe_malloc(argc*sizeof(char *));
for (i=1; i<argc; i++)
{
...
}



...EXAMPLE CODE for vendor_hostid.c...

#define LM_INTERNAL

#include "lmclient.h"
#include "lm_attr.h"
#include "string.h"

extern LM_HANDLE *lm_job; /* This must be the current job! */

/* This example returns only 1 hostid */
// #define VENDEF_ID_TYPE HOSTID_VENDOR+1
// #define VENDEF_ID_LABEL "VDH"
// #define VENDEF_ID "12345678"

/* NEW CODE: This example returns 2 hostids */

#define VENDEF_ID_TYPE HOSTID_VENDOR + 1
#define VENDEF_ID_TYPE2 HOSTID_VENDOR + 2

#define VENDEF_ID_LABEL "WEEKDAY" // WEEKDAY=ZZZ, as in Mon, Tue, etc.
#define VENDEF_ID_LABEL2 "SECRETWORD" // SECRETWORD=NotVerySecret

HOSTID * x_flexlm_gethostid(short idtype)
{
char debug_message[100] = {0};

HOSTID *h = l_new_hostid( );
memset(h, 0, sizeof(HOSTID));

printf(*\t[ x_flexlm_gethostid received type %d ]\n", idtype);

if (idtype == VENDEF_ID_TYPE)
{ // keyword value is abbreviated current weekday: "Mon", "Tue", etc.
time_t raw_time; struct tm *time_info; char weekday[10] = {0};
time(&raw_time); time_info = localtime(&raw_time);
strftime(weekday, 10, "%a", time_info);

printf("\t[ x_flexlm_gethostid says: WEEKDAY=%s ]\n", weekday);
// sprintf(debug_message, "##### VDH routine says: WEEKDAY=%s #####\n", weekday);
// ls_log_message(debug_message);

h->type = VENDEF_ID_TYPE;
strncpy(h->id.vendor, weekday, MAX_HOSTID_LEN);
h->id.vendor[MAX_HOSTID_LEN] = 0;
return(h);
}

if (idtype == VENDEF_ID_TYPE2)
{
h->type = VENDEF_ID_TYPE2;
strncpy(h->id.vendor, "NotVerySecret", MAX_HOSTID_LEN);
h->id.vendor[MAX_HOSTID_LEN] = 0;
return(h);
}
return ((HOSTID *)NULL);
}

void x_flexlm_newid(HOSTID *id)
{
LM_VENDOR_HOSTID h;
LM_VENDOR_HOSTID h2;

memset(&h, 0, sizeof(h));
memset(&h2, 0, sizeof(h2));

h.hostid_num = VENDEF_ID_TYPE;
h.label = VENDEF_ID_LABEL;

h.case_sensitive = 0;
h.get_vendor_id = x_flexlm_gethostid;

h2.hostid_num = VENDEF_ID_TYPE2;
h2.label = VENDEF_ID_LABEL2;

h2.case_sensitive = 0;
h2.get_vendor_id = x_flexlm_gethostid;

h.next = &h2; // This linked-list part is tricky to figure out.
// i.e., 2 VDH's would add
// h2.next = &h3;

if (lc_set_attr(lm_job, LM_A_VENDOR_ID_DECLARE, (LM_A_VAL_TYPE)&h))
lc_perror(lm_job, "LM_A_VENDOR_ID_DECLARE FAILED");

if (lc_set_attr(lm_job, LM_A_VENDOR_ID_DECLARE, (LM_A_VAL_TYPE)&h2))
lc_perror(lm_job, "LM_A_VENDOR_ID_DECLARE_FAILED");
}



...EXAMPLE WORKING LICENSE FILE called vdh.lic...

# Implement as a quoted, space-separated list of valid hostids
INCREMENT VDH demo 1.0 1-jan-2015 uncounted VENDOR_STRING="Greetings \
from a vendor-defined hostid!" \
HOSTID="WEEKDAY=TUE SECRETWORD=NotVerySercret" SIGN=0

# Or as individual hostids
INCREMENT VDH1 demo 1.0 1-jan-2015 uncounted VENDOR_STRING="Greetings \
from another vendor-defined hostid!" HOSTID=SECRETWORD=NotVerySercret SIGN=0
INCREMENT VDH2 demo 1.0 1-jan-2015 uncounted VENDOR_STRING="Greetings \
from a vendor-defined hostid!" HOSTID=WEEKDAY=WED SIGN=0

...EXAMPLE FAILING LICENSE FILE called vdh_bad.lic...

# Implement as a quoted, space-separated list of valid hostids
INCREMENT VDH demo 1.0 1-jan-2015 uncounted VENDOR_STRING="Greetings \
from a vendor-defined hostid!" HOSTID="WEEKDAY=SAT SECRETWORD=NotIt" SIGN=0

# Or as individual hostids
INCREMENT VDH1 demo 1.0 1-jan-2015 uncounted VENDOR_STRING="Greetings \
from a vendor-defined hostid!" HOSTID=WEEKDAY=SUN SIGN=0
INCREMENT VDH2 demo 1.0 1-jan-2015 uncounted VENDOR_STRING="Greetings \
from another vendor-defined hostid!" HOSTID=SECRETWORD=WrongGuess SIGN=0
Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Jan 12, 2010 03:49 PM
Updated by: