/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SCTP kernel Implementation * (C) Copyright IBM Corp. 2001, 2004 * Copyright (C) 1999-2001 Cisco, Motorola * * This file is part of the SCTP kernel implementation * * These are the definitions needed for the command object. * * Please send any bug reports or fixes you make to the * email address(es): * lksctp developers <[email protected]> * * Written or modified by: * La Monte H.P. Yarroll <[email protected]> * Karl Knutson <[email protected]> * Ardelle Fan <[email protected]> * Sridhar Samudrala <[email protected]> */ #ifndef __net_sctp_command_h__ #define __net_sctp_command_h__ #include <net/sctp/constants.h> #include <net/sctp/structs.h> enum sctp_verb { … }; /* How many commands can you put in an struct sctp_cmd_seq? * This is a rather arbitrary number, ideally derived from a careful * analysis of the state functions, but in reality just taken from * thin air in the hopes othat we don't trigger a kernel panic. */ #define SCTP_MAX_NUM_COMMANDS … sctp_arg; /* We are simulating ML type constructors here. * * SCTP_ARG_CONSTRUCTOR(NAME, TYPE, ELT) builds a function called * SCTP_NAME() which takes an argument of type TYPE and returns an * union sctp_arg. It does this by inserting the sole argument into * the ELT union element of a local union sctp_arg. * * E.g., SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) builds SCTP_I32(arg), * which takes an __s32 and returns a union sctp_arg containing the * __s32. So, after foo = SCTP_I32(arg), foo.i32 == arg. */ #define SCTP_ARG_CONSTRUCTOR(name, type, elt) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … /* protocol error */ SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … SCTP_ARG_CONSTRUCTOR(…) … static inline union sctp_arg SCTP_FORCE(void) { … } static inline union sctp_arg SCTP_NOFORCE(void) { … } static inline union sctp_arg SCTP_NULL(void) { … } struct sctp_cmd { … }; struct sctp_cmd_seq { … }; /* 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) { … } /* 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) { … } /* 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) { … } #endif /* __net_sctp_command_h__ */