/** * Compare two abstract data objects. * @arg a Abstract data object. * @arg b Another abstract data object. * @return An integer less than, equal to, or greater than zero if * a is found, respectively, to be less than, to match, or * be greater than b. */ int nl_data_cmp(struct nl_data *a, struct nl_data *b) { void *a_ = nl_data_get(a); void *b_ = nl_data_get(b); if (a_ && b_) return memcmp(a_, b_, nl_data_get_size(a)); else return -1; }
void *rtnl_cls_data(struct rtnl_cls *cls) { if (!cls->c_subdata) { struct rtnl_cls_ops *ops = cls->c_ops; if (!ops) { if (!cls->c_kind[0]) BUG(); ops = __rtnl_cls_lookup_ops(cls->c_kind); if (ops == NULL) return NULL; cls->c_ops = ops; } if (!ops->co_size) BUG(); if (!(cls->c_subdata = nl_data_alloc(NULL, ops->co_size))) return NULL; } return nl_data_get(cls->c_subdata); }