Exemplo n.º 1
0
/* Creates and returns an OpenFlow message of type OFPT_ERROR that conveys the
 * given 'error'.
 *
 * 'oh->version' determines the OpenFlow version of the error reply.
 * 'oh->xid' determines the xid of the error reply.
 * The error reply will contain an initial subsequence of 'oh', up to
 * 'oh->length' or 64 bytes, whichever is shorter.
 *
 * This function isn't appropriate for encoding OFPET_HELLO_FAILED error
 * messages.  Use ofperr_encode_hello() instead. */
struct ofpbuf *
ofperr_encode_reply(enum ofperr error, const struct ofp_header *oh)
{
    uint16_t len = ntohs(oh->length);

    return ofperr_encode_msg__(error, oh->version, oh->xid, oh, MIN(len, 64));
}
Exemplo n.º 2
0
/* Creates and returns an OpenFlow message of type OFPT_ERROR that conveys the
 * given 'error', in the error domain 'domain'.  The error message will include
 * the additional null-terminated text string 's'.
 *
 * If 'version' is an unknown version then OFP10_VERSION is used.
 * OFPET_HELLO_FAILED error messages are supposed to be backward-compatible,
 * so in theory this should work. */
struct ofpbuf *
ofperr_encode_hello(enum ofperr error, enum ofp_version ofp_version,
                    const char *s)
{
    return ofperr_encode_msg__(error, ofp_version, htonl(0), s, strlen(s));
}
Exemplo n.º 3
0
/* Creates and returns an OpenFlow message of type OFPT_ERROR that conveys the
 * given 'error'.
 *
 * 'oh->version' determines the OpenFlow version of the error reply.
 * 'oh->xid' determines the xid of the error reply.
 * The error reply will contain an initial subsequence of 'oh', up to
 * 'oh->length' (or however much fits).
 *
 * This function isn't appropriate for encoding OFPET_HELLO_FAILED error
 * messages.  Use ofperr_encode_hello() instead. */
struct ofpbuf *
ofperr_encode_reply(enum ofperr error, const struct ofp_header *oh)
{
    return ofperr_encode_msg__(error, oh->version, oh->xid,
                               oh, ntohs(oh->length));
}