lib/ofp-prop.c
/* Pulls a property, beginning with struct ofp_prop_header, from the beginning
 * of 'msg'.  Stores the type of the property in '*typep' and, if 'property' is
 * nonnull, the entire property, including the header, in '*property'.  Points
 * 'property->header' to the property header (which could be ofp_prop_header or
 * ofp_prop_experimenter) and 'property->msg' to just past it.  Returns 0 if
 * successful, otherwise an OpenFlow error code.
 *
 * This function treats property types 'min_exp' and larger as introducing
 * experimenter properties.  For most kinds of properties, 0xffff is the
 * appropriate value for 'min_exp', because 0xffff is the only property type
 * used for experimenters, but async config properties also use 0xfffe.  Use
 * 0x10000 (or higher) if experimenter properties are not supported.
 *
 * This function pulls the property's stated size padded out to a multiple of
 * 'alignment' bytes.  The common case in OpenFlow is an 'alignment' of 8, so
 * you can use ofpprop_pull() for that case. */
Pulls a property, beginning with struct ofp_prop_header, from the beginning
of 'msg'.

This function treats property types 'min_exp' and larger as introducing
experimenter properties.  For most kinds of properties, 0xffff is the
appropriate value for 'min_exp', because 0xffff is the only property type
used for experimenters, but async config properties also use 0xfffe.  Use
0x10000 (or higher) if experimenter properties are not supported.

This function pulls the property's stated size padded out to a multiple of
'alignment' bytes.  The common case in OpenFlow is an 'alignment' of 8, so
you can use ofpprop_pull() for that case.
Pulls a property beginning with struct ofp_prop_header from the beginning of ' msg ' . This function treats property types ' min_exp ' and larger as introducing experimenter properties . For most kinds of properties 0xffff is the appropriate value for ' min_exp ' because 0xffff is the only property type used for experimenters but async config properties also use 0xfffe . Use 0x10000 ( or higher ) if experimenter properties are not supported . This function pulls the property ' s stated size padded out to a multiple of ' alignment ' bytes . The common case in OpenFlow is an ' alignment ' of 8 so you can use ofpprop_pull () for that case .
enum ofperr
ofpprop_pull__(struct ofpbuf *msg, struct ofpbuf *property,
               unsigned int alignment, unsigned int min_exp,
               uint64_t *typep)
{
    struct ofp_prop_header *oph;
    unsigned int padded_len;
    unsigned int len;
    if (msg->size < sizeof *oph) {
        return OFPERR_OFPBPC_BAD_LEN;
    }
    oph = msg->data;
    len = ntohs(oph->len);
    padded_len = ROUND_UP(len, alignment);
    if (len < sizeof *oph || padded_len > msg->size) {
        return OFPERR_OFPBPC_BAD_LEN;
    }
    uint16_t type = ntohs(oph->type);
    if (type < min_exp) {
        *typep = type;
    } else {
        struct ofp_prop_experimenter *ope = msg->data;
        if (len < sizeof *ope) {
            return OFPERR_OFPBPC_BAD_LEN;
        }
        if (!ope->experimenter) {
            return OFPERR_OFPBPC_BAD_EXPERIMENTER;
        }
        *typep = OFPPROP_EXP(ntohl(ope->experimenter), ntohl(ope->exp_type));
    }
    if (property) {
        ofpbuf_use_const(property, msg->data, len);
        property->header = property->data;
        property->msg = ((uint8_t *) property->data
                         + (type < min_exp
                            ? sizeof(struct ofp_prop_header)
                            : sizeof(struct ofp_prop_experimenter)));
    }
    ofpbuf_pull(msg, padded_len);
    return 0;
}
enum ofperr ofpprop_pull__ ( struct ofpbuf * msg , struct ofpbuf * property , unsigned int alignment , unsigned int min_exp , uint64_t * typep ) { struct ofp_prop_header * oph ; unsigned int padded_len ; unsigned int len ; if ( msg -> size < sizeof * oph ) { return OFPERR_OFPBPC_BAD_LEN ; } oph = msg -> data ; len = ntohs ( oph -> len ) ; padded_len = ROUND_UP ( len , alignment ) ; if ( len < sizeof * oph || padded_len > msg -> size ) { return OFPERR_OFPBPC_BAD_LEN ; } uint16_t type = ntohs ( oph -> type ) ; if ( type < min_exp ) { * typep = type ; } else { struct ofp_prop_experimenter * ope = msg -> data ; if ( len < sizeof * ope ) { return OFPERR_OFPBPC_BAD_LEN ; } if ( ! ope -> experimenter ) { return OFPERR_OFPBPC_BAD_EXPERIMENTER ; } * typep = OFPPROP_EXP ( ntohl ( ope -> experimenter ) , ntohl ( ope -> exp_type ) ) ; } if ( property ) { ofpbuf_use_const ( property , msg -> data , len ) ; property -> header = property -> data ; property -> msg = ( ( uint8_t * ) property -> data + ( type < min_exp ? sizeof ( struct ofp_prop_header ) : sizeof ( struct ofp_prop_experimenter ) ) ) ; } ofpbuf_pull ( msg , padded_len ) ; return 0 ; }
Pulls a property, beginning with struct ofp_prop_header, from the beginning
 of 'msg'.
Pulls a property beginning with struct ofp_prop_header from the beginning of ' msg ' .
/* Reject experimenter 0 because it yields ambiguity with standard
             * property types. */