Пример #1
0
size_t
ofl_structs_group_desc_stats_pack(struct ofl_group_desc_stats *src, struct ofp_group_desc_stats *dst, struct ofl_exp *exp) {
    size_t total_len, len;
    uint8_t *data;
    size_t i;

    total_len = sizeof(struct ofp_group_desc_stats) +
            ofl_structs_buckets_ofp_total_len(src->buckets, src->buckets_num, exp);

    dst->length =       htons( total_len);
    dst->type =                src->type;
    dst->pad = 0x00;
    dst->group_id =     htonl( src->group_id);

    data = (uint8_t *)dst->buckets;

    for (i=0; i<src->buckets_num; i++) {
        len = ofl_structs_bucket_pack(src->buckets[i], (struct ofp_bucket *)data, exp);
        data += len;
    }

    return total_len;
}
static int
ofl_msg_pack_group_mod(struct ofl_msg_group_mod *msg, uint8_t **buf, size_t *buf_len, struct ofl_exp *exp) {
    struct ofp_group_mod *group_mod;
    uint8_t *ptr;
    int i;

    *buf_len = sizeof(struct ofp_group_mod) + ofl_structs_buckets_ofp_total_len(msg->buckets, msg->buckets_num, exp);;
    *buf     = (uint8_t *)malloc(*buf_len);

    group_mod = (struct ofp_group_mod *)(*buf);
    group_mod->command  = htons(msg->command);
    group_mod->type     =       msg->type;
    group_mod->pad = 0x00;
    group_mod->group_id = htonl(msg->group_id);

    ptr = (*buf) + sizeof(struct ofp_group_mod);

    for (i=0; i<msg->buckets_num; i++) {
        ptr += ofl_structs_bucket_pack(msg->buckets[i], (struct ofp_bucket *)ptr, exp);
    }

    return 0;
}
Пример #3
0
size_t
ofl_structs_group_desc_stats_ofp_len(struct ofl_group_desc_stats *stats, struct ofl_exp *exp) {
    return sizeof(struct ofp_group_desc_stats) +
           ofl_structs_buckets_ofp_total_len(stats->buckets, stats->buckets_num, exp);
}