Exemplo n.º 1
0
/**
 * @name fab_host_clone_prop -
 * @brief Clone src host properties to dst host  
 *
 * Note: Tenant network and host routes would not be cloned
 */
static fab_host_t * 
fab_host_clone_prop(fab_host_t *dst, fab_host_t *src)
{
    if (!dst) {
        dst = fab_zalloc(sizeof(fab_host_t));
    } else {
        memset(dst, 0, sizeof(*dst)); 
    }

    c_rw_lock_init(&dst->lock);
    memcpy(&dst->sw, &src->sw, sizeof(fab_host_sw_t));
    memcpy(&dst->hkey, &src->hkey, sizeof(fab_hkey_t));
    dst->dfl_gw = src->dfl_gw;
    dst->dead = src->dead;

    return dst;
}
Exemplo n.º 2
0
/**
 * fab_host_create -
 *
 * Allocate and initialize a host struct  
 */
static fab_host_t *
fab_host_create(uint64_t dpid, uint32_t sw_alias, struct flow *fl)
{
    fab_host_t *host;

    host = fab_zalloc(sizeof(fab_host_t));

    c_rw_lock_init(&host->lock);
    host->sw.swid = dpid;
    host->sw.alias = sw_alias;
    host->sw.port = ntohs(fl->in_port);
    FAB_MK_TEN_NET_ID(host->hkey.tn_id, 
                      fab_extract_tenant_id(fl), 
                      fab_extract_network_id(fl)); 
    host->hkey.host_ip = ntohl(fl->nw_src);
    memcpy(host->hkey.host_mac, fl->dl_src, 6);
    host->dfl_gw = fl->FL_DFL_GW;

    return host;
}
Exemplo n.º 3
0
/**
 * @name fab_host_create
 * @brief Allocate and initialize a host struct
 */
static fab_host_t *
fab_host_create(uint64_t dpid, uint32_t sw_alias, struct flow *fl, 
        uint8_t *tenant_id, uint8_t *network_id)
{
    fab_host_t *host;

    host = fab_zalloc(sizeof(fab_host_t));

    c_rw_lock_init(&host->lock);
    host->sw.swid = dpid;
    host->sw.alias = sw_alias;
    host->sw.port = ntohl(fl->in_port);
    FAB_MK_TEN_NET_ID(host->hkey.tn_id, 
                      fab_tenant_nw_uuid_hash_func(tenant_id), 
                      fab_tenant_nw_uuid_hash_func(network_id)); 
    host->hkey.host_ip = ntohl(fl->ip.nw_src);
    memcpy(host->hkey.host_mac, fl->dl_src, 6);
    memcpy(host->tenant_id, tenant_id, sizeof(uuid_t));
    memcpy(host->network_id, network_id, sizeof(uuid_t));
    host->dfl_gw = fl->FL_DFL_GW;

    return host;
}