iPXE
params.h
Go to the documentation of this file.
1#ifndef _IPXE_PARAMS_H
2#define _IPXE_PARAMS_H
3
4/** @file
5 *
6 * Request parameters
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <ipxe/list.h>
14#include <ipxe/refcnt.h>
15
16/** A request parameter list */
17struct parameters {
18 /** Reference count */
19 struct refcnt refcnt;
20 /** List of all parameter lists */
22 /** Name */
23 const char *name;
24 /** Request method */
25 const char *method;
26 /** Parameters */
28};
29
30/** A request parameter */
31struct parameter {
32 /** List of request parameters */
34 /** Key */
35 const char *key;
36 /** Value */
37 const char *value;
38 /** Flags */
39 unsigned int flags;
40};
41
42/** Request parameter is a form parameter */
43#define PARAMETER_FORM 0x0001
44
45/** Request parameter is a header parameter */
46#define PARAMETER_HEADER 0x0002
47
48/**
49 * Increment request parameter list reference count
50 *
51 * @v params Parameter list, or NULL
52 * @ret params Parameter list as passed in
53 */
54static inline __attribute__ (( always_inline )) struct parameters *
55params_get ( struct parameters *params ) {
56 ref_get ( &params->refcnt );
57 return params;
58}
59
60/**
61 * Decrement request parameter list reference count
62 *
63 * @v params Parameter list, or NULL
64 */
65static inline __attribute__ (( always_inline )) void
66params_put ( struct parameters *params ) {
67 ref_put ( &params->refcnt );
68}
69
70/**
71 * Claim ownership of request parameter list
72 *
73 * @v params Parameter list
74 * @ret params Parameter list
75 */
76static inline __attribute__ (( always_inline )) struct parameters *
77claim_parameters ( struct parameters *params ) {
78
79 /* Remove from list of parameter lists */
80 list_del ( &params->list );
81
82 return params;
83}
84
85/** Iterate over all request parameters in a list */
86#define for_each_param( param, params ) \
87 list_for_each_entry ( (param), &(params)->entries, list )
88
89extern struct parameters * find_parameters ( const char *name );
90extern struct parameters * create_parameters ( const char *name,
91 const char *method );
92extern struct parameter * add_parameter ( struct parameters *params,
93 const char *key, const char *value,
94 unsigned int flags );
95
96#endif /* _IPXE_PARAMS_H */
union @162305117151260234136356364136041353210355154177 key
pseudo_bit_t value[0x00020]
Definition arbel.h:2
const char * name
Definition ath9k_hw.c:1986
uint8_t flags
Flags.
Definition ena.h:7
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951
uint8_t method
Definition ib_mad.h:3
#define __attribute__(x)
Definition compiler.h:10
struct parameters * create_parameters(const char *name, const char *method)
Create request parameter list.
Definition params.c:89
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value, unsigned int flags)
Add request parameter.
Definition params.c:145
struct parameters * find_parameters(const char *name)
Find request parameter list by name.
Definition params.c:69
Linked lists.
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
Reference counting.
#define ref_get(refcnt)
Get additional reference to object.
Definition refcnt.h:93
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107
A doubly-linked list entry (or list head).
Definition list.h:19
A request parameter.
Definition params.h:31
const char * key
Key.
Definition params.h:35
unsigned int flags
Flags.
Definition params.h:39
const char * value
Value.
Definition params.h:37
struct list_head list
List of request parameters.
Definition params.h:33
A request parameter list.
Definition params.h:17
struct list_head list
List of all parameter lists.
Definition params.h:21
const char * name
Name.
Definition params.h:23
struct list_head entries
Parameters.
Definition params.h:27
struct refcnt refcnt
Reference count.
Definition params.h:19
const char * method
Request method.
Definition params.h:25