include/net/sctp/command.h

Source file repositories/reference/linux-study-clean/include/net/sctp/command.h

File Facts

System
Linux kernel
Corpus path
include/net/sctp/command.h
Extension
.h
Size
8778 bytes
Lines
237
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct sctp_cmd {
	union sctp_arg obj;
	enum sctp_verb verb;
};

struct sctp_cmd_seq {
	struct sctp_cmd cmds[SCTP_MAX_NUM_COMMANDS];
	struct sctp_cmd *last_used_slot;
	struct sctp_cmd *next_cmd;
};


/* Initialize a block of memory as a command sequence.
 * Return 0 if the initialization fails.
 */
static inline int sctp_init_cmd_seq(struct sctp_cmd_seq *seq)
{
	/* cmds[] is filled backwards to simplify the overflow BUG() check */
	seq->last_used_slot = seq->cmds + SCTP_MAX_NUM_COMMANDS;
	seq->next_cmd = seq->last_used_slot;
	return 1;		/* We always succeed.  */
}


/* Add a command to an struct sctp_cmd_seq.
 *
 * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
 * to wrap data which goes in the obj argument.
 */
static inline void sctp_add_cmd_sf(struct sctp_cmd_seq *seq,
				   enum sctp_verb verb, union sctp_arg obj)
{
	struct sctp_cmd *cmd = seq->last_used_slot - 1;

	BUG_ON(cmd < seq->cmds);

	cmd->verb = verb;
	cmd->obj = obj;
	seq->last_used_slot = cmd;
}

/* Return the next command structure in an sctp_cmd_seq.
 * Return NULL at the end of the sequence.
 */
static inline struct sctp_cmd *sctp_next_cmd(struct sctp_cmd_seq *seq)
{
	if (seq->next_cmd <= seq->last_used_slot)
		return NULL;

	return --seq->next_cmd;
}

#endif /* __net_sctp_command_h__ */

Annotation

Implementation Notes