void compute_vendorids (void) { int i; vchar_t vid; for (i = 0; i < NUMVENDORIDS; i++) { /* VENDORID_DPD is not a MD5 sum... */ if(i == VENDORID_DPD){ all_vendor_ids[i].hash = vmalloc(sizeof(vendorid_dpd_hash)); if (all_vendor_ids[i].hash == NULL) { plog(LLV_ERROR, LOCATION, NULL, "unable to get memory for VID hash\n"); exit(1); /* this really shouldn't happen */ } memcpy(all_vendor_ids[i].hash->v, vendorid_dpd_hash, sizeof(vendorid_dpd_hash)); continue; } vid.v = (char *) all_vendor_ids[i].string; vid.l = strlen(vid.v); all_vendor_ids[i].hash = eay_md5_one(&vid); if (all_vendor_ids[i].hash == NULL) plog(LLV_ERROR, LOCATION, NULL, "unable to hash vendor ID string\n"); /* Special cases */ all_vendor_ids[i].hash = vendorid_fixup(all_vendor_ids[i].id, all_vendor_ids[i].hash); } }
/* * set hashed vendor id. * hash function is always MD5. */ vchar_t * set_vendorid(int vendorid) { vchar_t vid, *vidhash; if (vendorid == VENDORID_UNKNOWN) { /* * The default unknown ID gets translated to * KAME/racoon. */ vendorid = VENDORID_KAME; } if (vendorid < 0 || vendorid >= NUMVENDORIDS) { plog(LLV_ERROR, LOCATION, NULL, "invalid vendor ID index: %d\n", vendorid); return (NULL); } vid.v = (char *) vendorid_strings[vendorid]; vid.l = strlen(vendorid_strings[vendorid]); vidhash = eay_md5_one(&vid); if (vidhash == NULL) plog(LLV_ERROR, LOCATION, NULL, "unable to hash vendor ID string\n"); return vidhash; }