iPXE
interface.h File Reference

Object interfaces. More...

#include <stddef.h>
#include <stdarg.h>
#include <ipxe/refcnt.h>

Go to the source code of this file.

Data Structures

struct  interface_operation
 An object interface operation. More...
struct  interface_descriptor
 An object interface descriptor. More...
struct  interface
 An object interface. More...

Macros

#define INTF_OP(op_type, object_type, op_func)
 Define an object interface operation.
#define UNUSED_INTF_OP(op_type, object_type, op_func)
 Define an unused object interface operation.
#define intf_offset(object_type, intf)
#define INTF_DESC(object_type, intf, operations)
 Define an object interface descriptor.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
 Define an object interface descriptor with pass-through interface.
#define INTF_DESC_PURE(operations)
 Define an object interface descriptor for a pure-interface object.
#define intf_close_TYPE(object_type)
#define intf_poke_TYPE(object_type)
#define INTF_INIT(descriptor)
 Initialise a static object interface.
#define intf_get_dest_op_no_passthru(intf, type, dest)
 Get object interface destination and operation method (without pass-through)
#define intf_get_dest_op(intf, type, dest)
 Get object interface destination and operation method.
#define INTF_COL(intf)
 Find debugging colourisation for an object interface.
#define INTF_FMT   "%p+%zx"
 printf() format string for INTF_DBG()
#define INTF_DBG(intf)
 printf() arguments for representing an object interface
#define INTF_INTF_FMT   INTF_FMT "->" INTF_FMT
 printf() format string for INTF_INTF_DBG()
#define INTF_INTF_DBG(intf, dest)
 printf() arguments for representing an object interface pair

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
void intf_plug (struct interface *intf, struct interface *dest)
 Plug an object interface into a new destination object interface.
void intf_plug_plug (struct interface *a, struct interface *b)
 Plug two object interfaces together.
void intf_unplug (struct interface *intf)
 Unplug an object interface.
void intf_nullify (struct interface *intf)
 Ignore all further operations on an object interface.
struct interfaceintf_get (struct interface *intf)
 Increment reference count on an object interface.
void intf_put (struct interface *intf)
 Decrement reference count on an object interface.
void * __attribute__ ((pure)) intf_object(struct interface *intf)
void * intf_get_dest_op_no_passthru_untyped (struct interface *intf, void *type, struct interface **dest)
 Get object interface destination and operation method (without pass-through)
void * intf_get_dest_op_untyped (struct interface *intf, void *type, struct interface **dest)
 Get object interface destination and operation method.
void intf_close (struct interface *intf, int rc)
 Close an object interface.
void intf_shutdown (struct interface *intf, int rc)
 Shut down an object interface.
void intfs_vshutdown (va_list intfs, int rc)
 Shut down multiple object interfaces.
void intfs_shutdown (int rc,...) __attribute__((sentinel))
 Shut down multiple object interfaces.
void intf_restart (struct interface *intf, int rc)
 Shut down and restart an object interface.
void intfs_vrestart (va_list intfs, int rc)
 Shut down and restart multiple object interfaces.
void intfs_restart (int rc,...) __attribute__((sentinel))
 Shut down and restart multiple object interfaces.
void intf_insert (struct interface *intf, struct interface *upper, struct interface *lower)
 Insert a filter interface.
void intf_poke (struct interface *intf, void(type)(struct interface *intf))
 Poke an object interface.
static void intf_init (struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
 Initialise an object interface.
static void intf_temp_init (struct interface *intf, struct interface *original)
 Initialise a temporary outbound-only object interface.
static struct interfaceintf_origin (struct interface *intf)
 Get original interface.
static void intf_reinit (struct interface *intf)
 Reinitialise an object interface.

Variables

struct interface_descriptor null_intf_desc
 Null interface descriptor.
struct interface null_intf
 The null interface.

Detailed Description

Object interfaces.

Definition in file interface.h.

Macro Definition Documentation

◆ INTF_OP

#define INTF_OP ( op_type,
object_type,
op_func )
Value:
{ \
.type = op_type, \
.func = ( ( ( ( typeof ( op_func ) * ) NULL ) == \
( ( op_type ## _TYPE ( object_type ) * ) NULL ) ) \
? op_func : op_func ), \
}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48

Define an object interface operation.

Parameters
op_typeOperation type
object_typeImplementing method's expected object type
op_funcImplementing method
Return values
opObject interface operation

Definition at line 33 of file interface.h.

33#define INTF_OP( op_type, object_type, op_func ) { \
34 .type = op_type, \
35 .func = ( ( ( ( typeof ( op_func ) * ) NULL ) == \
36 ( ( op_type ## _TYPE ( object_type ) * ) NULL ) ) \
37 ? op_func : op_func ), \
38 }

◆ UNUSED_INTF_OP

#define UNUSED_INTF_OP ( op_type,
object_type,
op_func )
Value:
{ \
.type = NULL, \
.func = ( ( ( ( typeof ( op_func ) * ) NULL ) == \
( ( op_type ## _TYPE ( object_type ) * ) NULL ) ) \
? NULL : NULL ), \
}

Define an unused object interface operation.

Parameters
op_typeOperation type
object_typeImplementing method's expected object type
op_funcImplementing method
Return values
opObject interface operation

Definition at line 48 of file interface.h.

48#define UNUSED_INTF_OP( op_type, object_type, op_func ) { \
49 .type = NULL, \
50 .func = ( ( ( ( typeof ( op_func ) * ) NULL ) == \
51 ( ( op_type ## _TYPE ( object_type ) * ) NULL ) ) \
52 ? NULL : NULL ), \
53 }

◆ intf_offset

#define intf_offset ( object_type,
intf )
Value:
( ( ( ( typeof ( ( ( object_type * ) NULL )->intf ) * ) NULL ) \
== ( ( struct interface * ) NULL ) ) \
? offsetof ( object_type, intf ) \
: offsetof ( object_type, intf ) )
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
An object interface.
Definition interface.h:125

Definition at line 67 of file interface.h.

67#define intf_offset( object_type, intf ) \
68 ( ( ( ( typeof ( ( ( object_type * ) NULL )->intf ) * ) NULL ) \
69 == ( ( struct interface * ) NULL ) ) \
70 ? offsetof ( object_type, intf ) \
71 : offsetof ( object_type, intf ) )

◆ INTF_DESC

#define INTF_DESC ( object_type,
intf,
operations )
Value:
{ \
.offset = intf_offset ( object_type, intf ), \
.op = operations, \
.num_op = ( sizeof ( operations ) / \
sizeof ( operations[0] ) ), \
.passthru_offset = 0, \
}
#define intf_offset(object_type, intf)
Definition interface.h:67

Define an object interface descriptor.

Parameters
object_typeContaining object data type
intfInterface name (i.e. field within object data type)
operationsObject interface operations array
Return values
descObject interface descriptor

Definition at line 81 of file interface.h.

81#define INTF_DESC( object_type, intf, operations ) { \
82 .offset = intf_offset ( object_type, intf ), \
83 .op = operations, \
84 .num_op = ( sizeof ( operations ) / \
85 sizeof ( operations[0] ) ), \
86 .passthru_offset = 0, \
87 }

◆ INTF_DESC_PASSTHRU

#define INTF_DESC_PASSTHRU ( object_type,
intf,
operations,
passthru )
Value:
{ \
.offset = offsetof ( object_type, intf ), \
.op = operations, \
.num_op = ( sizeof ( operations ) / \
sizeof ( operations[0] ) ), \
.passthru_offset = ( intf_offset ( object_type, passthru ) - \
intf_offset ( object_type, intf ) ), \
}

Define an object interface descriptor with pass-through interface.

Parameters
object_typeContaining object data type
intfInterface name (i.e. field within object data type)
operationsObject interface operations array
passthruPass-through interface name
Return values
descObject interface descriptor

Definition at line 98 of file interface.h.

98#define INTF_DESC_PASSTHRU( object_type, intf, operations, passthru ) { \
99 .offset = offsetof ( object_type, intf ), \
100 .op = operations, \
101 .num_op = ( sizeof ( operations ) / \
102 sizeof ( operations[0] ) ), \
103 .passthru_offset = ( intf_offset ( object_type, passthru ) - \
104 intf_offset ( object_type, intf ) ), \
105 }

◆ INTF_DESC_PURE

#define INTF_DESC_PURE ( operations)
Value:
{ \
.offset = 0, \
.op = operations, \
.num_op = ( sizeof ( operations ) / \
sizeof ( operations[0] ) ), \
.passthru_offset = 0, \
}

Define an object interface descriptor for a pure-interface object.

Parameters
operationsObject interface operations array
Return values
descObject interface descriptor

A pure-interface object is an object that consists solely of a single interface.

Definition at line 116 of file interface.h.

116#define INTF_DESC_PURE( operations ) { \
117 .offset = 0, \
118 .op = operations, \
119 .num_op = ( sizeof ( operations ) / \
120 sizeof ( operations[0] ) ), \
121 .passthru_offset = 0, \
122 }

◆ intf_close_TYPE

#define intf_close_TYPE ( object_type)
Value:
typeof ( void ( object_type, int rc ) )
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3

Definition at line 177 of file interface.h.

177#define intf_close_TYPE( object_type ) \
178 typeof ( void ( object_type, int rc ) )

Referenced by intf_close().

◆ intf_poke_TYPE

#define intf_poke_TYPE ( object_type)
Value:
typeof ( void ( object_type ) )

Definition at line 191 of file interface.h.

191#define intf_poke_TYPE( object_type ) \
192 typeof ( void ( object_type ) )

Referenced by intf_poke().

◆ INTF_INIT

#define INTF_INIT ( descriptor)
Value:
{ \
.dest = &null_intf, \
.refcnt = NULL, \
.desc = &(descriptor), \
.original = { \
.desc = &(descriptor), \
}, \
}
struct interface null_intf
The null interface.
Definition interface.c:66

Initialise a static object interface.

Parameters
descriptorObject interface descriptor

Definition at line 218 of file interface.h.

218#define INTF_INIT( descriptor ) { \
219 .dest = &null_intf, \
220 .refcnt = NULL, \
221 .desc = &(descriptor), \
222 .original = { \
223 .desc = &(descriptor), \
224 }, \
225 }

Referenced by ifpoller_wait().

◆ intf_get_dest_op_no_passthru

#define intf_get_dest_op_no_passthru ( intf,
type,
dest )
Value:
( ( type ## _TYPE ( void * ) * ) \
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
uint32_t type
Operating system type.
Definition ena.h:1
void * intf_get_dest_op_no_passthru_untyped(struct interface *intf, void *type, struct interface **dest)
Get object interface destination and operation method (without pass-through)
Definition interface.c:188

Get object interface destination and operation method (without pass-through)

Parameters
intfObject interface
typeOperation type
Return values
destDestination interface
funcImplementing method, or NULL

Definition at line 258 of file interface.h.

258#define intf_get_dest_op_no_passthru( intf, type, dest ) \
259 ( ( type ## _TYPE ( void * ) * ) \
260 intf_get_dest_op_no_passthru_untyped ( intf, type, dest ) )

Referenced by xfer_vredirect().

◆ intf_get_dest_op

#define intf_get_dest_op ( intf,
type,
dest )
Value:
( ( type ## _TYPE ( void * ) * ) \
void * intf_get_dest_op_untyped(struct interface *intf, void *type, struct interface **dest)
Get object interface destination and operation method.
Definition interface.c:213

Get object interface destination and operation method.

Parameters
intfObject interface
typeOperation type
Return values
destDestination interface
funcImplementing method, or NULL

Definition at line 270 of file interface.h.

270#define intf_get_dest_op( intf, type, dest ) \
271 ( ( type ## _TYPE ( void * ) * ) \
272 intf_get_dest_op_untyped ( intf, type, dest ) )

Referenced by acpi_describe(), ata_command(), block_capacity(), block_read(), block_read_capacity(), block_write(), edd_describe(), efi_describe(), identify_device(), intf_close(), job_progress(), peerdisc_stat(), resolv_done(), scsi_command(), scsi_response(), xfer_alloc_iob(), xfer_buffer(), xfer_deliver(), and xfer_window().

◆ INTF_COL

#define INTF_COL ( intf)
Value:
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition interface.c:160
static struct interface * intf_origin(struct interface *intf)
Get original interface.
Definition interface.h:246

Find debugging colourisation for an object interface.

Parameters
intfObject interface
Return values
colDebugging colourisation

Use as the first argument to DBGC() or equivalent macro.

Definition at line 282 of file interface.h.

Referenced by intf_close(), intf_plug(), intf_restart(), intf_shutdown(), intf_unplug(), job_progress(), resolv_done(), xfer_alloc_iob(), xfer_deliver(), xfer_open_socket(), xfer_open_uri(), xfer_open_uri_string(), xfer_seek(), xfer_vopen(), and xfer_vredirect().

◆ INTF_FMT

#define INTF_FMT   "%p+%zx"

◆ INTF_DBG

#define INTF_DBG ( intf)
Value:
intf_object ( intf_origin ( intf ) ), \
intf_origin ( intf )->desc->offset

printf() arguments for representing an object interface

Parameters
intfObject interface
Return values
argsprintf() argument list corresponding to INTF_FMT

Definition at line 293 of file interface.h.

293#define INTF_DBG( intf ) \
294 intf_object ( intf_origin ( intf ) ), \
295 intf_origin ( intf )->desc->offset

Referenced by intf_plug(), intf_restart(), intf_shutdown(), xfer_open_socket(), xfer_open_uri(), xfer_open_uri_string(), xfer_seek(), and xfer_vopen().

◆ INTF_INTF_FMT

#define INTF_INTF_FMT   INTF_FMT "->" INTF_FMT

◆ INTF_INTF_DBG

#define INTF_INTF_DBG ( intf,
dest )
Value:
INTF_DBG ( intf ), INTF_DBG ( dest )
#define INTF_DBG(intf)
printf() arguments for representing an object interface
Definition interface.h:293

printf() arguments for representing an object interface pair

Parameters
intfObject interface
destDestination object interface
Return values
argsprintf() argument list corresponding to INTF_INTF_FMT

Definition at line 307 of file interface.h.

Referenced by intf_close(), intf_plug(), intf_unplug(), job_progress(), resolv_done(), xfer_alloc_iob(), xfer_deliver(), and xfer_vredirect().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ intf_plug()

void intf_plug ( struct interface * intf,
struct interface * dest )
extern

Plug an object interface into a new destination object interface.

Parameters
intfObject interface
destNew destination object interface

The reference to the existing destination interface is dropped, a reference to the new destination interface is obtained, and the interface is updated to point to the new destination interface.

Definition at line 84 of file interface.c.

84 {
85
86 if ( intf == &null_intf )
87 return;
88
89 DBGC ( INTF_COL ( intf ),
90 "INTF " INTF_INTF_FMT " replug to " INTF_FMT "\n",
91 INTF_INTF_DBG ( intf, intf->dest ), INTF_DBG ( dest ) );
92
93 intf_get ( dest );
94 intf_put ( intf->dest );
95 intf->dest = dest;
96}
#define DBGC(...)
Definition compiler.h:505
struct interface * intf_get(struct interface *intf)
Increment reference count on an object interface.
Definition interface.c:140
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition interface.c:150
#define INTF_INTF_FMT
printf() format string for INTF_INTF_DBG()
Definition interface.h:298
#define INTF_COL(intf)
Find debugging colourisation for an object interface.
Definition interface.h:282
#define INTF_FMT
printf() format string for INTF_DBG()
Definition interface.h:285
#define INTF_INTF_DBG(intf, dest)
printf() arguments for representing an object interface pair
Definition interface.h:307
struct interface * dest
Destination object interface.
Definition interface.h:134

References DBGC, dest, interface::dest, interface::intf, INTF_COL, INTF_DBG, INTF_FMT, intf_get(), INTF_INTF_DBG, INTF_INTF_FMT, intf_put(), and null_intf.

Referenced by intf_plug_plug(), and xfer_vredirect().

◆ intf_plug_plug()

void intf_plug_plug ( struct interface * a,
struct interface * b )
extern

Plug two object interfaces together.

Parameters
aObject interface A
bObject interface B

Plugs interface A into interface B, and interface B into interface A. (The basic plug() function is unidirectional; this function is merely a shorthand for two calls to plug(), hence the name.)

Definition at line 108 of file interface.c.

108 {
109 intf_plug ( a, b );
110 intf_plug ( b, a );
111}
void intf_plug(struct interface *intf, struct interface *dest)
Plug an object interface into a new destination object interface.
Definition interface.c:84

References intf_plug().

Referenced by aoedev_ata_command(), aoedev_cfg_command(), ata_open(), atadev_command(), create_downloader(), create_pinger(), create_validator(), dns_resolv(), efi_local_open(), fc_els_request(), fc_els_respond(), fc_port_open(), fc_xchg_originate(), fcpdev_scsi_command(), ftp_open(), http_connect(), http_open(), http_transfer_complete(), hw_open(), ib_cmrc_open(), ifpoller_wait(), intf_insert(), ipair_create(), iscsi_scsi_command(), nfs_open(), numeric_resolv(), peerblk_open(), peermux_filter(), ping_open(), resolv(), resolv_setting(), scsi_open(), scsidev_command(), slam_open(), srp_open(), srpdev_scsi_command(), start_dhcp(), start_dhcpv6(), start_ipv6conf(), start_ntp(), start_pxebs(), sync(), tcp_open(), tftp_core_open(), udp_open_common(), usbblk_scsi_command(), and xfer_open_named_socket().

◆ intf_unplug()

void intf_unplug ( struct interface * intf)
extern

Unplug an object interface.

Parameters
intfObject interface

Definition at line 118 of file interface.c.

118 {
119 DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " unplug\n",
120 INTF_INTF_DBG ( intf, intf->dest ) );
121 intf_put ( intf->dest );
122 intf->dest = &null_intf;
123}

References DBGC, interface::dest, interface::intf, INTF_COL, INTF_INTF_DBG, INTF_INTF_FMT, intf_put(), and null_intf.

Referenced by intf_shutdown(), named_resolv_done(), and xfer_vredirect().

◆ intf_nullify()

void intf_nullify ( struct interface * intf)
extern

Ignore all further operations on an object interface.

Parameters
intfObject interface

Definition at line 130 of file interface.c.

130 {
131 intf->desc = &null_intf_desc;
132}
struct interface_descriptor null_intf_desc
Null interface descriptor.
Definition interface.c:62
struct interface_descriptor * desc
Interface descriptor.
Definition interface.h:146

References interface::desc, interface::intf, and null_intf_desc.

Referenced by intf_shutdown(), intfs_vshutdown(), named_resolv_done(), and peermux_close().

◆ intf_get()

struct interface * intf_get ( struct interface * intf)
extern

Increment reference count on an object interface.

Parameters
intfObject interface
Return values
intfObject interface

Definition at line 140 of file interface.c.

140 {
141 ref_get ( intf->refcnt );
142 return intf;
143}
#define ref_get(refcnt)
Get additional reference to object.
Definition refcnt.h:93
struct refcnt * refcnt
Reference counter.
Definition interface.h:140

References interface::intf, ref_get, and interface::refcnt.

Referenced by intf_get_dest_op_no_passthru_untyped(), intf_insert(), and intf_plug().

◆ intf_put()

void intf_put ( struct interface * intf)
extern

◆ __attribute__()

void * __attribute__ ( (pure) )
extern

References dest, rc, and type.

◆ intf_get_dest_op_no_passthru_untyped()

void * intf_get_dest_op_no_passthru_untyped ( struct interface * intf,
void * type,
struct interface ** dest )
extern

Get object interface destination and operation method (without pass-through)

Parameters
intfObject interface
typeOperation type
Return values
destDestination interface
funcImplementing method, or NULL

Definition at line 188 of file interface.c.

190 {
192 struct interface_operation *op;
193 unsigned int i;
194
195 *dest = intf_get ( intf->dest );
196 desc = (*dest)->desc;
197 for ( i = desc->num_op, op = desc->op ; i ; i--, op++ ) {
198 if ( op->type == type )
199 return op->func;
200 }
201
202 return NULL;
203}
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
An object interface descriptor.
Definition interface.h:56
An object interface operation.
Definition interface.h:18

References desc, dest, interface::dest, intf_get(), NULL, op, and type.

Referenced by intf_get_dest_op_untyped().

◆ intf_get_dest_op_untyped()

void * intf_get_dest_op_untyped ( struct interface * intf,
void * type,
struct interface ** dest )
extern

Get object interface destination and operation method.

Parameters
intfObject interface
typeOperation type
Return values
destDestination interface
funcImplementing method, or NULL

Definition at line 213 of file interface.c.

214 {
215 void *func;
216
217 while ( 1 ) {
218
219 /* Search for an implementing method provided by the
220 * current destination interface.
221 */
223 if ( func )
224 return func;
225
226 /* Pass through to the underlying interface, if applicable */
227 if ( ! ( intf = intf_get_passthru ( *dest ) ) )
228 return NULL;
229 intf_put ( *dest );
230 }
231}
static struct interface * intf_get_passthru(struct interface *intf)
Get pass-through interface.
Definition interface.c:170

References dest, interface_operation::func, intf_get_dest_op_no_passthru_untyped(), intf_get_passthru(), intf_put(), NULL, and type.

Referenced by intf_poke().

◆ intf_close()

void intf_close ( struct interface * intf,
int rc )
extern

Close an object interface.

Parameters
intfObject interface
rcReason for close

Note that this function merely informs the destination object that the interface is about to be closed; it doesn't actually disconnect the interface. In most cases, you probably want to use intf_shutdown() or intf_restart() instead.

Definition at line 250 of file interface.c.

250 {
251 struct interface *dest;
252 intf_close_TYPE ( void * ) *op =
254 void *object = intf_object ( dest );
255
256 DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " close (%s)\n",
257 INTF_INTF_DBG ( intf, dest ), strerror ( rc ) );
258
259 if ( op ) {
260 op ( object, rc );
261 } else {
262 /* Default is to restart the interface */
263 intf_restart ( dest, rc );
264 }
265
266 intf_put ( dest );
267}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition interface.c:250
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
Definition interface.c:344
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition interface.h:270
#define intf_close_TYPE(object_type)
Definition interface.h:177
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
struct interface * intf
Original interface.
Definition interface.h:159

References DBGC, dest, interface::intf, intf_close(), intf_close_TYPE, INTF_COL, intf_get_dest_op, INTF_INTF_DBG, INTF_INTF_FMT, intf_object(), intf_put(), intf_restart(), op, rc, and strerror().

Referenced by ifconf_progress(), iflinkwait_progress(), intf_close(), intf_shutdown(), netdev_close(), sync_progress(), and xfer_vredirect().

◆ intf_shutdown()

void intf_shutdown ( struct interface * intf,
int rc )
extern

Shut down an object interface.

Parameters
intfObject interface
rcReason for close

Blocks further operations from being received via the interface, executes a close operation on the destination interface, and unplugs the interface.

Definition at line 279 of file interface.c.

279 {
280 struct interface tmp;
281
282 DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " shutting down (%s)\n",
283 INTF_DBG ( intf ), strerror ( rc ) );
284
285 /* Block further operations */
286 intf_nullify ( intf );
287
288 /* Transfer destination to temporary interface */
289 intf_temp_init ( &tmp, intf );
290 tmp.dest = intf->dest;
291 intf->dest = &null_intf;
292
293 /* Notify destination of close via temporary interface */
294 intf_close ( &tmp, rc );
295
296 /* Unplug temporary interface */
297 intf_unplug ( &tmp );
298}
void intf_unplug(struct interface *intf)
Unplug an object interface.
Definition interface.c:118
void intf_nullify(struct interface *intf)
Ignore all further operations on an object interface.
Definition interface.c:130
static void intf_temp_init(struct interface *intf, struct interface *original)
Initialise a temporary outbound-only object interface.
Definition interface.h:233
unsigned long tmp
Definition linux_pci.h:65

References DBGC, interface::dest, interface::intf, intf_close(), INTF_COL, INTF_DBG, INTF_FMT, intf_nullify(), intf_temp_init(), intf_unplug(), null_intf, rc, strerror(), and tmp.

Referenced by aoecmd_close(), aoedev_close(), aoedev_config_done(), atacmd_close(), atadev_close(), blktrans_close(), comboot_resolv_close(), dhcp_finished(), dhcpv6_finished(), dns_done(), downloader_finished(), efi_download_close(), efi_local_close(), fc_els_close(), fc_ns_query_close(), fc_peer_close(), fc_port_close(), fc_ulp_close(), fc_xchg_close(), fcoe_close(), fcpcmd_close(), fcpdev_close(), ftp_done(), http_conn_close(), http_transfer_complete(), hw_finished(), ib_cmrc_close(), ib_srp_close(), imux_shutdown(), intf_restart(), intfs_vshutdown(), ipair_close(), ipv6conf_done(), named_close(), nfs_deliver(), nfs_done(), nfs_pm_deliver(), nslookup_close(), ntp_close(), numeric_step(), peerblk_close(), peermux_close(), peermux_info_close(), ping_close(), pinger_close(), posix_file_finished(), pxe_tftp_close(), resmux_close(), slam_finished(), srpcmd_close(), srpdev_close(), tcp_close(), tftp_done(), tls_close(), udp_close(), validator_finished(), and xcm_destroy().

◆ intfs_vshutdown()

void intfs_vshutdown ( va_list intfs,
int rc )
extern

Shut down multiple object interfaces.

Parameters
intfsObject interfaces
rcReason for close

Definition at line 306 of file interface.c.

306 {
307 struct interface *intf;
308 va_list tmp;
309
310 /* Nullify all interfaces to avoid potential loops */
311 va_copy ( tmp, intfs );
312 while ( ( intf = va_arg ( tmp, struct interface * ) ) )
313 intf_nullify ( intf );
314 va_end ( tmp );
315
316 /* Shut down all interfaces */
317 while ( ( intf = va_arg ( intfs, struct interface * ) ) )
318 intf_shutdown ( intf, rc );
319}
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition interface.c:279
#define va_copy(dest, src)
Definition stdarg.h:11
#define va_arg(ap, type)
Definition stdarg.h:9
#define va_end(ap)
Definition stdarg.h:10
__builtin_va_list va_list
Definition stdarg.h:7

References interface::intf, intf_nullify(), intf_shutdown(), rc, tmp, va_arg, va_copy, and va_end.

Referenced by intfs_shutdown(), and intfs_vrestart().

◆ intfs_shutdown()

void intfs_shutdown ( int rc,
... )
extern

Shut down multiple object interfaces.

Parameters
rcReason for close
...Object interfaces

Definition at line 327 of file interface.c.

327 {
328 va_list intfs;
329
330 va_start ( intfs, rc );
331 intfs_vshutdown ( intfs, rc );
332 va_end ( intfs );
333}
void intfs_vshutdown(va_list intfs, int rc)
Shut down multiple object interfaces.
Definition interface.c:306
#define va_start(ap, last)
Definition stdarg.h:8

References intfs_vshutdown(), rc, va_end, and va_start.

Referenced by http_close(), iscsi_close(), scsicmd_close(), scsidev_close(), and usbblk_remove().

◆ intf_restart()

void intf_restart ( struct interface * intf,
int rc )
extern

Shut down and restart an object interface.

Parameters
intfObject interface
rcReason for close

Shuts down the interface, then unblocks operations that were blocked during shutdown.

Definition at line 344 of file interface.c.

344 {
345
346 /* Shut down the interface */
347 intf_shutdown ( intf, rc );
348
349 DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " restarting\n",
350 INTF_DBG ( intf ) );
351
352 /* Restore the interface descriptor. Must be done after
353 * shutdown (rather than inhibiting intf_shutdown() from
354 * nullifying the descriptor) in order to avoid a potential
355 * infinite loop as the intf_close() operations on each side
356 * of the link call each other recursively.
357 */
358 intf_reinit ( intf );
359}
static void intf_reinit(struct interface *intf)
Reinitialise an object interface.
Definition interface.h:314

References DBGC, interface::intf, INTF_COL, INTF_DBG, INTF_FMT, intf_reinit(), intf_shutdown(), and rc.

Referenced by apply_syslog_settings(), apply_syslogs_settings(), efi_pxe_tftp_close(), efi_pxe_udp_close(), fc_peer_plogi(), fc_peer_plogi_done(), fc_port_examine(), fc_port_flogi_done(), fc_port_login(), fc_port_ns_plogi_done(), fc_ulp_examine(), fc_ulp_prli_done(), fcoe_reset(), http_block_read(), http_block_read_capacity(), http_conn_close(), http_conn_xfer_close(), http_reopen(), http_transfer_complete(), imux_close(), imux_start_pair(), intf_close(), iscsi_close_connection(), iscsi_command_close(), iscsi_scsi_done(), monojob_close(), netdev_config_close(), netdev_configure(), peerblk_raw_close(), peerblk_raw_open(), peerblk_raw_rx(), peerblk_reset(), peerblk_retrieval_close(), peerblk_retrieval_open(), peerblk_retrieval_rx(), peerdisc_socket_close(), peerdisc_socket_open(), peermux_block_close(), pxenv_udp_close(), pxenv_udp_open(), resmux_child_close(), sandev_command_close(), sanpath_close(), scsicmd_done(), scsidev_ready(), syslogs_close(), tftp_reopen(), tftp_reopen_mc(), tftp_timer_expired(), tls_validator_done(), usbblk_stop(), validator_start_download(), validator_start_ocsp(), validator_xfer_close(), xcm_close(), xcm_reopen(), and xfer_vreopen().

◆ intfs_vrestart()

void intfs_vrestart ( va_list intfs,
int rc )
extern

Shut down and restart multiple object interfaces.

Parameters
intfsObject interfaces
rcReason for close

Definition at line 367 of file interface.c.

367 {
368 struct interface *intf;
369 va_list tmp;
370
371 /* Shut down all interfaces */
372 va_copy ( tmp, intfs );
374 va_end ( tmp );
375
376 /* Reinitialise all interfaces */
377 while ( ( intf = va_arg ( intfs, struct interface * ) ) )
378 intf_reinit ( intf );
379}

References interface::intf, intf_reinit(), intfs_vshutdown(), rc, tmp, va_arg, va_copy, and va_end.

Referenced by intfs_restart().

◆ intfs_restart()

void intfs_restart ( int rc,
... )
extern

Shut down and restart multiple object interfaces.

Parameters
rcReason for close
...Object interfaces

Definition at line 387 of file interface.c.

387 {
388 va_list intfs;
389
390 va_start ( intfs, rc );
391 intfs_vrestart ( intfs, rc );
392 va_end ( intfs );
393}
void intfs_vrestart(va_list intfs, int rc)
Shut down and restart multiple object interfaces.
Definition interface.c:367

References intfs_vrestart(), rc, va_end, and va_start.

Referenced by http_transfer_complete(), sanpath_close(), and usbblk_scsi_close().

◆ intf_insert()

void intf_insert ( struct interface * intf,
struct interface * upper,
struct interface * lower )
extern

Insert a filter interface.

Parameters
intfObject interface
upperUpper end of filter
lowerLower end of filter

Definition at line 402 of file interface.c.

403 {
404 struct interface *dest = intf->dest;
405
406 intf_get ( dest );
407 intf_plug_plug ( intf, upper );
408 intf_plug_plug ( lower, dest );
409 intf_put ( dest );
410}
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition interface.c:108

References dest, interface::dest, interface::intf, intf_get(), intf_plug_plug(), and intf_put().

Referenced by add_tls(), and block_translate().

◆ intf_poke()

void intf_poke ( struct interface * intf,
void(type)(struct interface *intf)  )
extern

Poke an object interface.

Parameters
intfObject interface
typeOperation type

This is a helper function to implement methods which take no parameters and return nothing.

Definition at line 421 of file interface.c.

422 {
423 struct interface *dest;
424 intf_poke_TYPE ( void * ) *op =
426 void *object = intf_object ( dest );
427
428 if ( op ) {
429 op ( object );
430 } else {
431 /* Default is to do nothing */
432 }
433
434 intf_put ( dest );
435}
#define intf_poke_TYPE(object_type)
Definition interface.h:191

References dest, interface::intf, intf_get_dest_op_untyped(), intf_object(), intf_poke_TYPE, intf_put(), op, and type.

Referenced by pool_recycle(), pool_reopen(), and xfer_window_changed().

◆ intf_init()

void intf_init ( struct interface * intf,
struct interface_descriptor * desc,
struct refcnt * refcnt )
inlinestatic

Initialise an object interface.

Parameters
intfObject interface
descObject interface descriptor
refcntContaining object reference counter, or NULL

Definition at line 204 of file interface.h.

206 {
207 intf->dest = &null_intf;
208 intf->refcnt = refcnt;
209 intf->desc = desc;
210 intf->original.desc = desc;
211}
union interface::@153016120005256257222347015034114015314175051044 original
Original interface properties.
A reference counter.
Definition refcnt.h:27

References desc, interface::desc, interface::dest, interface::intf, null_intf, interface::original, and interface::refcnt.

Referenced by add_tls(), alloc_netdev(), alloc_sandev(), aoecmd_create(), aoedev_open(), ata_open(), atadev_command(), block_translate(), create_downloader(), create_pinger(), create_validator(), dns_resolv(), efi_download_start(), efi_local_open(), efi_pxe_install(), fc_els_create(), fc_ns_query(), fc_peer_create(), fc_port_open(), fc_ulp_create(), fc_xchg_create(), fcoe_probe(), fcpdev_open(), fcpdev_scsi_command(), ftp_open(), http_connect(), http_open(), hw_open(), ib_cmrc_open(), ib_srp_open(), imux_probe(), ipair_create(), iscsi_open(), nfs_open(), numeric_resolv(), open(), peerblk_open(), peermux_filter(), ping_open(), pxe_tftp_open(), resolv(), resolv_setting(), scsi_open(), scsidev_command(), slam_open(), srp_open(), srpdev_scsi_command(), start_dhcp(), start_dhcpv6(), start_ipv6conf(), start_ntp(), start_pxebs(), tcp_open(), tftp_core_open(), udp_open_common(), usbblk_probe(), xcm_create(), and xfer_open_named_socket().

◆ intf_temp_init()

void intf_temp_init ( struct interface * intf,
struct interface * original )
inlinestatic

Initialise a temporary outbound-only object interface.

Parameters
intfTemporary outbound-only object interface
originalOriginal object interface

Definition at line 233 of file interface.h.

234 {
235 intf->dest = &null_intf;
236 intf->desc = NULL;
237 intf->original.intf = original;
238}

References interface::desc, interface::dest, interface::intf, NULL, null_intf, and interface::original.

Referenced by intf_shutdown(), and xfer_vredirect().

◆ intf_origin()

struct interface * intf_origin ( struct interface * intf)
inlinestatic

Get original interface.

Parameters
intfObject interface (possibly a temporary interface)
Return values
intfOriginal object interface

Definition at line 246 of file interface.h.

246 {
247 return ( intf->desc ? intf : intf->original.intf );
248}

References interface::desc, interface::intf, and interface::original.

◆ intf_reinit()

void intf_reinit ( struct interface * intf)
inlinestatic

Reinitialise an object interface.

Parameters
intfObject interface

Definition at line 314 of file interface.h.

314 {
315
316 /* Restore original interface descriptor */
317 intf->desc = intf->original.desc;
318}

References interface::desc, interface::intf, and interface::original.

Referenced by intf_restart(), and intfs_vrestart().

Variable Documentation

◆ null_intf_desc

struct interface_descriptor null_intf_desc
extern

Null interface descriptor.

Definition at line 62 of file interface.c.

Referenced by intf_nullify(), and numeric_resolv().

◆ null_intf

struct interface null_intf
extern

The null interface.

Definition at line 66 of file interface.c.

Referenced by intf_init(), intf_plug(), intf_shutdown(), intf_temp_init(), and intf_unplug().