Esempio n. 1
0
/* Appends to 'b' a set of OXM or NXM matches for the IPv4 or IPv6 fields in
 * 'match'.  */
static void
nxm_put_ip(struct ofpbuf *b, const struct match *match, enum ofp_version oxm)
{
    const struct flow *flow = &match->flow;

    if (flow->dl_type == htons(ETH_TYPE_IP)) {
        nxm_put_32m(b, mf_oxm_header(MFF_IPV4_SRC, oxm),
                    flow->nw_src, match->wc.masks.nw_src);
        nxm_put_32m(b, mf_oxm_header(MFF_IPV4_DST, oxm),
                    flow->nw_dst, match->wc.masks.nw_dst);
    } else {
        nxm_put_ipv6(b, mf_oxm_header(MFF_IPV6_SRC, oxm),
                     &flow->ipv6_src, &match->wc.masks.ipv6_src);
        nxm_put_ipv6(b, mf_oxm_header(MFF_IPV6_DST, oxm),
                     &flow->ipv6_dst, &match->wc.masks.ipv6_dst);
    }

    nxm_put_frag(b, match, oxm);

    if (match->wc.masks.nw_tos & IP_DSCP_MASK) {
        if (oxm) {
            nxm_put_8(b, mf_oxm_header(MFF_IP_DSCP_SHIFTED, oxm),
                      flow->nw_tos >> 2);
        } else {
            nxm_put_8(b, mf_oxm_header(MFF_IP_DSCP, oxm),
                      flow->nw_tos & IP_DSCP_MASK);
        }
    }
Esempio n. 2
0
static void
nxm_put_ip(struct ofpbuf *b, const struct match *match,
           uint8_t icmp_proto, uint32_t icmp_type, uint32_t icmp_code,
           bool oxm)
{
    const struct flow *flow = &match->flow;

    nxm_put_frag(b, match);

    if (match->wc.masks.nw_tos & IP_DSCP_MASK) {
        if (oxm) {
            nxm_put_8(b, OXM_OF_IP_DSCP, flow->nw_tos >> 2);
        } else {
            nxm_put_8(b, NXM_OF_IP_TOS, flow->nw_tos & IP_DSCP_MASK);
        }
    }
Esempio n. 3
0
static void
nxm_put_8m(struct ofpbuf *b, uint32_t header, uint8_t value, uint8_t mask)
{
    switch (mask) {
    case 0:
        break;

    case UINT8_MAX:
        nxm_put_8(b, header, value);
        break;

    default:
        nxm_put_header(b, NXM_MAKE_WILD_HEADER(header));
        ofpbuf_put(b, &value, sizeof value);
        ofpbuf_put(b, &mask, sizeof mask);
    }
}
Esempio n. 4
0
static void
nxm_put_frag(struct ofpbuf *b, const struct match *match, enum ofp_version oxm)
{
    uint32_t header = mf_oxm_header(MFF_IP_FRAG, oxm);
    uint8_t nw_frag = match->flow.nw_frag;
    uint8_t nw_frag_mask = match->wc.masks.nw_frag;

    switch (nw_frag_mask) {
    case 0:
        break;

    case FLOW_NW_FRAG_MASK:
        nxm_put_8(b, header, nw_frag);
        break;

    default:
        nxm_put_8m(b, header, nw_frag, nw_frag_mask & FLOW_NW_FRAG_MASK);
        break;
    }
}
Esempio n. 5
0
static void
nxm_put_frag(struct ofpbuf *b, const struct match *match)
{
    uint8_t nw_frag = match->flow.nw_frag;
    uint8_t nw_frag_mask = match->wc.masks.nw_frag;

    switch (nw_frag_mask) {
    case 0:
        break;

    case FLOW_NW_FRAG_MASK:
        nxm_put_8(b, NXM_NX_IP_FRAG, nw_frag);
        break;

    default:
        nxm_put_8m(b, NXM_NX_IP_FRAG, nw_frag,
                   nw_frag_mask & FLOW_NW_FRAG_MASK);
        break;
    }
}