173{
174 int err;
175
176 if (ops->co_protocol != NETLINK_GENERIC) {
177 err = nl_error(EINVAL, "cache operations not for protocol " \
178 "NETLINK_GENERIC (protocol=%s)",
179 ops->co_protocol);
180 goto errout;
181 }
182
183 if (ops->co_hdrsize < GENL_HDRSIZE(0)) {
184 err = nl_error(EINVAL, "co_hdrsize too short, probably " \
185 "not including genlmsghdr, minsize=%d",
186 GENL_HDRSIZE(0));
187 goto errout;
188 }
189
190 if (ops->co_genl == NULL) {
191 err = nl_error(EINVAL, "co_genl is NULL, must provide " \
192 "valid genl operations");
193 goto errout;
194 }
195
196 ops->co_genl->o_cache_ops = ops;
197 ops->co_genl->o_name = ops->co_msgtypes[0].
mt_name;
198 ops->co_genl->o_family = ops->co_msgtypes[0].
mt_id;
200
201
202
203 nl_list_add_tail(&ops->co_genl->o_list, &genl_ops_list);
204
206errout:
207 return err;
208}
int nl_cache_mngt_register(struct nl_cache_ops *ops)
Register a set of cache operations.
int(* co_msg_parser)(struct nl_cache_ops *, struct sockaddr_nl *, struct nlmsghdr *, struct nl_parser_param *)
Called whenever a message was received that needs to be parsed.
int mt_id
Netlink message type.
char * mt_name
Name of operation for human-readable printing.