>Object Identifiers

Object Identifiers

When you refer to object identifiers in your application, you need to be aware that SR and Z39.50 use two different set of OIDs to refer to the same objects. To handle this easily, YAZ provides a utility module to Z39.50 ASN.1 which provides an internal representation of the OIDs used in both protocols. Each oid is described by a structure:

typedef struct oident
    enum oid_proto proto;
    enum oid_class class;
    enum oid_value value;
    int oidsuffix[OID_SIZE];
    char *desc;
} oident;

The proto field can be set to either PROTO_SR or PROTO_Z3950. The class might be, say, CLASS_RECSYN, and the value might be VAL_USMARC for the USMARC record format. Functions

int *oid_ent_to_oid(struct oident *ent, int *dst);
struct oident *oid_getentbyoid(int *o);

are provided to map between object identifiers and database entries. If you store a member of the oid_proto type in your association state information, it's a simple matter, at runtime, to generate the correct OID when you need it. For decoding, you can simply ignore the proto field, or if you're strict, you can verify that your peer is using the OID family from the correct protocol. The desc field is a short, human-readable name for the PDU, useful mainly for diagnostic output.

Note: The old function oid_getoidbyent still exists but is not thread safe. Use oid_ent_to_oid instead and pass an array of size OID_SIZE.

Note: Plans are underway to merge the two protocols into a single definition, with one set of object identifiers. When this happens, the oid module will no longer be required to support protocol independence, but it should still be useful as a simple OID database.