[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / gpxe / interface.h
blob114ebf32d16fdbf3d0d63bf82868d2e2cd044b22
1 #ifndef _GPXE_INTERFACE_H
2 #define _GPXE_INTERFACE_H
4 /** @file
6 * Object communication interfaces
8 */
10 FILE_LICENCE ( GPL2_OR_LATER );
12 #include <gpxe/refcnt.h>
14 /** An object communication interface */
15 struct interface {
16 /** Destination interface
18 * When messages are sent via this interface, they will be
19 * delivered to the destination interface.
21 * This pointer may never be NULL. When the interface is
22 * unplugged, it should point to a null interface.
24 struct interface *dest;
25 /** Reference counter
27 * If this interface is not part of a reference-counted
28 * object, this field may be NULL.
30 struct refcnt *refcnt;
33 /**
34 * Increment reference count on an interface
36 * @v intf Interface
37 * @ret intf Interface
39 static inline __attribute__ (( always_inline )) struct interface *
40 intf_get ( struct interface *intf ) {
41 ref_get ( intf->refcnt );
42 return intf;
45 /**
46 * Decrement reference count on an interface
48 * @v intf Interface
50 static inline __attribute__ (( always_inline )) void
51 intf_put ( struct interface *intf ) {
52 ref_put ( intf->refcnt );
55 extern void plug ( struct interface *intf, struct interface *dest );
56 extern void plug_plug ( struct interface *a, struct interface *b );
58 #endif /* _GPXE_INTERFACE_H */