Since many protocols' UPI operations look very similar, the x-kernel provides some library operations which do much of the standard work of some of the operations. Many protocols can call these default operations and greatly simplify their own implementations of these routines.
Binds key to an enable object with hlpRcv and hlpType. If a previous binding exists for the given key and hlps,
the reference count of that enable object will be increased.
defaultOpenEnable will fail if a previous binding exists for
this key that does not match the hlps.
xkern_return_t defaultOpenEnable
(
Map m,
XObj hlpRcv,
XObj hlpType,
void * key
)
Undoes the effect of a previous defaultOpenEnable.
Returns failure if no appropriate enable object exists (e.g., if
nothing exists for the given key or if the hlps don't match the
saved values in the enable object.)
xkern_return_t defaultOpenDisable
(
Map m,
XObj hlpRcv,
XObj hlpType,
void * key
)
Removes all enable objects bound in map with hlpRcv.
If f is non-zero, it is called with the (key, Enable *) pair for each Enable object in the map before it is removed.
xkern_return_t defaultOpenDisableAll
(
Map m,
XObj hlpRcv,
DisableAllFunc f
)
typedef void (*DisableAllFunc )
(
void * key,
Enable * e
)
Designed to be used by virtual protocols. In addition to the binding
performed by defaultOpenEnable, an xOpenEnable is
performed on each lower protocol in the null-terminated array
llp (using participants p,
causing the lower protocols to deliver packets for
hlpType to the virtual protocol self. If any of these
xOpenEnables fail, defaultVirtualOpenEnable backs out of
the entire operation.
Assumes that the passive map is keyed on hlpType.
Undoes the effect of a previous defaultVirtualOpenEnable.
Here is an example of how a protocol might simplify its
enable/disable routines using these operations:
defaultOpenDisable
defaultOpenDisableAll
defaultVirtualOpenEnable
defaultVirtualOpenDisable
Usage
static xkern_return_t
yapOpenEnable( XObj self, XObj hlpRcv, XObj hlpType, Part *p )
{
long key;
PState *ps = self->state;
key = getRelProtNum(hlpType, self));
return defaultOpenEnable(ps->passive_map, hlpRcv, hlpType, &key);
}
static xkern_return_t
yapOpenDisable( XObj self, XObj hlpRcv, XObj hlpType, Part *p )
{
long key;
PState *ps = self->state;
key = getRelProtNum(hlpType, self));
return defaultOpenDisable(ps->passive_map, hlpRcv, hlpType, &key);
}
static xkern_return_t
yapOpenDisableAll( XObj self, XObj hlpRcv )
{
PState *ps = self->state;
return defaultOpenDisableAll(ps->passive_map, hlpRcv, 0);
}
Next: Participant Library
Up: Uniform Protocol Interface
Previous: Usage Rules