+struct oident *oid_addent (int *oid, int proto, int oclass,
+ const char *desc, int value)
+{
+ struct oident *oident;
+
+ nmem_critical_enter ();
+ oident = oid_getentbyoid_x (oid);
+ if (!oident)
+ {
+ char desc_str[200];
+ struct oident_list *oident_list;
+ oident_list = (struct oident_list *) malloc (sizeof(*oident_list));
+ oident = &oident_list->oident;
+ oident->proto = proto;
+ oident->oclass = oclass;
+
+ if (!desc)
+ {
+ int i;
+
+ sprintf (desc_str, "%d", *oid);
+ for (i = 1; oid[i] >= 0; i++)
+ sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
+ desc = desc_str;
+ }
+ oident->desc = (char *) malloc (strlen(desc)+1);
+ strcpy (oident->desc, desc);
+ if (value == VAL_DYNAMIC)
+ oident->value = ++oid_value_dynamic;
+ else
+ oident->value = value;
+ oid_oidcpy (oident->oidsuffix, oid);
+ oident_list->next = oident_table;
+ oident_table = oident_list;
+ }
+ nmem_critical_leave ();
+ return oident;
+}
+
+struct oident *oid_getentbyoid(int *oid)
+{
+ struct oident *oident;
+ oid_init ();
+ oident = oid_getentbyoid_x (oid);
+ if (!oident)
+ oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL,
+ NULL, VAL_DYNAMIC);
+ return oident;
+}
+
+static oid_value oid_getval_raw(const char *name)
+{
+ int val = 0, i = 0, oid[OID_SIZE];
+ struct oident *oident;
+
+ while (isdigit (*name))
+ {
+ val = val*10 + (*name - '0');
+ name++;
+ if (*name == '.')
+ {
+ if (i < OID_SIZE-1)
+ oid[i++] = val;
+ val = 0;
+ name++;
+ }
+ }
+ oid[i] = val;
+ oid[i+1] = -1;
+ oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
+ VAL_DYNAMIC);
+ return oident->value;
+}
+