tools/net/ynl/lib/ynl.h

Source file repositories/reference/linux-study-clean/tools/net/ynl/lib/ynl.h

File Facts

System
Linux kernel
Corpus path
tools/net/ynl/lib/ynl.h
Extension
.h
Size
3631 bytes
Lines
144
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ynl_error {
	enum ynl_error_code code;
	unsigned int attr_offs;
	char msg[512];
};

/**
 * struct ynl_family - YNL family info
 * Family description generated by codegen. Pass to ynl_sock_create().
 */
struct ynl_family {
/* private: */
	const char *name;
	size_t hdr_len;
	bool is_classic;
	__u16 classic_id;
	const struct ynl_ntf_info *ntf_info;
	unsigned int ntf_info_size;
};

/**
 * struct ynl_sock - YNL wrapped netlink socket
 * @err: YNL error descriptor, cleared on every request.
 */
struct ynl_sock {
	struct ynl_error err;

/* private: */
	const struct ynl_family *family;
	int socket;
	__u32 seq;
	__u32 portid;
	__u16 family_id;

	unsigned int n_mcast_groups;
	struct {
		unsigned int id;
		char name[GENL_NAMSIZ];
	} *mcast_groups;

	struct ynl_ntf_base_type *ntf_first;
	struct ynl_ntf_base_type **ntf_last_next;

	struct nlmsghdr *nlh;
	const struct ynl_policy_nest *req_policy;
	size_t req_hdr_len;
	unsigned char *tx_buf;
	unsigned char *rx_buf;
	unsigned char raw_buf[];
};

/**
 * struct ynl_string - parsed individual string
 * @len: length of the string (excluding terminating character)
 * @str: value of the string
 *
 * Parsed and nul-terminated string. This struct is only used for arrays of
 * strings. Non-array string members are placed directly in respective types.
 */
struct ynl_string {
	unsigned int len;
	char str[];
};

struct ynl_sock *
ynl_sock_create(const struct ynl_family *yf, struct ynl_error *e);
void ynl_sock_destroy(struct ynl_sock *ys);

#define ynl_dump_foreach(dump, iter)					\
	for (typeof(dump->obj) *iter = &dump->obj;			\
	     !ynl_dump_obj_is_last(iter);				\
	     iter = ynl_dump_obj_next(iter))

/**
 * ynl_dump_empty() - does the dump have no entries
 * @dump: pointer to the dump list, as returned by a dump call
 *
 * Check if the dump is empty, i.e. contains no objects.
 * Dump calls return NULL on error, and terminator element if empty.
 */
static inline bool ynl_dump_empty(void *dump)
{
	return dump == (void *)YNL_LIST_END;
}

int ynl_subscribe(struct ynl_sock *ys, const char *grp_name);
int ynl_socket_get_fd(struct ynl_sock *ys);
int ynl_ntf_check(struct ynl_sock *ys);

/**

Annotation

Implementation Notes