uint32_t, int);
+ /**
+ * update function
+ *
+ * Will be called when the object given by first argument
+ * needs to be updated with the contents of the second object
+ *
+ * The function must return 0 for success and error for failure
+ * to update. In case of failure its assumed that the original
+ * object is not touched
+ */
+ int (*oo_update)(struct nl_object *, struct nl_object *);
+
char *(*oo_attrs2str)(int, char *, size_t);
/**
struct nl_object **);
extern void nl_object_free(struct nl_object *);
extern struct nl_object * nl_object_clone(struct nl_object *obj);
+extern int nl_object_update(struct nl_object *dst,
+ struct nl_object *src);
extern void nl_object_get(struct nl_object *);
extern void nl_object_put(struct nl_object *);
extern int nl_object_shared(struct nl_object *);
case NL_ACT_DEL:
old = nl_cache_search(cache, obj);
if (old) {
+ /*
+ * Some objects types might support merging the new
+ * object with the old existing cache object.
+ * Handle them first.
+ */
+ if (nl_object_update(old, obj) == 0) {
+ cb(cache, old, NL_ACT_CHANGE, data);
+ nl_object_put(obj);
+ return 0;
+ }
+
nl_cache_remove(old);
if (type->mt_act == NL_ACT_DEL) {
if (cb)
return new;
}
+/**
+ * Merge a cacheable object
+ * @arg dst object to be merged into
+ * @arg src new object to be merged into dst
+ *
+ * @return 0 or a negative error code.
+ */
+int nl_object_update(struct nl_object *dst, struct nl_object *src)
+{
+ struct nl_object_ops *ops = obj_ops(dst);
+
+ if (ops->oo_update)
+ return ops->oo_update(dst, src);
+
+ return -NLE_OPNOTSUPP;
+}
+
/**
* Free a cacheable object
* @arg obj object to free