Ejemplo n.º 1
0
Archivo: anytimer.c Proyecto: yumm007/C
int at_wait_job(int job_num) {
	struct at_job cur;
	int ret;

	cur.job_num = job_num;
	if ((ret = link_del(&cur, tim_link)) == 0)
		num_bit[job_num] = 0;
	return ret;
}
Ejemplo n.º 2
0
/**
 * delMacvtap:
 * @ifname : The name of the macvtap interface
 * @linkdev: The interface name of the NIC to connect to the external bridge
 * @virtPortProfile: pointer to object holding the virtual port profile data
 *
 * Delete an interface given its name. Disassociate
 * it with the switch if port profile parameters
 * were provided.
 */
void
delMacvtap(const char *ifname,
           const unsigned char *macaddr,
           const char *linkdev,
           virVirtualPortProfileParamsPtr virtPortProfile)
{
    if (ifname) {
        vpDisassociatePortProfileId(ifname, macaddr,
                                    linkdev,
                                    virtPortProfile);
        link_del(ifname);
    }
}
Ejemplo n.º 3
0
int pomme_rpcs_distroy(pomme_rpcs_t *rpcs)
{
    int ret = 0;
    assert( rpcs != NULL );
    
    pomme_func_t *pos = NULL;
    pomme_link_t *head = &rpcs->func;

    list_for_each_entry(pos, head, next)
    {
	link_del(&pos->next);
	/* the pomme_arg_t->args[i]->data is NULL in func list*/
	POMME_ARG_F(pos->arg);
	free(pos);
    }
Ejemplo n.º 4
0
Archivo: anytimer.c Proyecto: yumm007/C
static int clean_node(struct at_job *cur) {
	struct at_job tmp;
	
		if (cur->job_rep_time == REP_FOREVER || --cur->job_rep_time > 0) {
			if (cur->job_org_val < next_alm) 
				sub_each(cur->job_org_val);
			memcpy(&tmp, cur, sizeof(*cur));
			tmp.job_val = cur->job_org_val;
			if ((tmp.job_arg = malloc(tmp.job_arg_size)) == NULL)
				return -1; 
			memcpy(tmp.job_arg, cur->job_arg, cur->job_arg_size);
			link_add(&tmp, tim_link);
			link_del(cur, tim_link);
		} else 
			cur->job_sta = AT_INVAL;
	return 0;
}
Ejemplo n.º 5
0
int main(void)
{
	struct student *head;
	struct student *p0;
	int num; 
	printf("\n"); 
	printf("\n");              
	printf("\n/////////学生信息系统/////////\n");
	head=link_creat();
	link_printf(head);
	printf("输入要删除的学号\n");
	scanf("%d",&num);   
	printf("..........\n");
	head=link_del(head,num);
	p0=(struct student *)malloc(LEN);
	printf("请输入学号 名字 性别 年纪\n");
	scanf("%ld %s %c %d",&p0->num,p0->name,&p0->sex,&p0->age);
	head=link_insert(head,p0);
	link_printf(head);
	free(p0);
	return 0;	
}
Ejemplo n.º 6
0
/**
 * openMacvtapTap:
 * Create an instance of a macvtap device and open its tap character
 * device.
 * @tgifname: Interface name that the macvtap is supposed to have. May
 *    be NULL if this function is supposed to choose a name
 * @macaddress: The MAC address for the macvtap device
 * @linkdev: The interface name of the NIC to connect to the external bridge
 * @mode: int describing the mode for 'bridge', 'vepa' or 'private'.
 * @vnet_hdr: 1 to enable IFF_VNET_HDR, 0 to disable it
 * @vmuuid: The UUID of the VM the macvtap belongs to
 * @virtPortProfile: pointer to object holding the virtual port profile data
 * @res_ifname: Pointer to a string pointer where the actual name of the
 *     interface will be stored into if everything succeeded. It is up
 *     to the caller to free the string.
 *
 * Returns file descriptor of the tap device in case of success,
 * negative value otherwise with error reported.
 *
 */
int
openMacvtapTap(const char *tgifname,
               const unsigned char *macaddress,
               const char *linkdev,
               int mode,
               int vnet_hdr,
               const unsigned char *vmuuid,
               virVirtualPortProfileParamsPtr virtPortProfile,
               char **res_ifname)
{
    const char *type = "macvtap";
    int c, rc;
    char ifname[IFNAMSIZ];
    int retries, do_retry = 0;
    uint32_t macvtapMode = macvtapModeFromInt(mode);
    const char *cr_ifname;
    int ifindex;

    *res_ifname = NULL;

    if (tgifname) {
        if(ifaceGetIndex(false, tgifname, &ifindex) == 0) {
            if (STRPREFIX(tgifname,
                          MACVTAP_NAME_PREFIX)) {
                goto create_name;
            }
            virReportSystemError(errno,
                                 _("Interface %s already exists"), tgifname);
            return -1;
        }
        cr_ifname = tgifname;
        rc = link_add(type, macaddress, 6, tgifname, linkdev,
                      macvtapMode, &do_retry);
        if (rc)
            return -1;
    } else {
create_name:
        retries = 5;
        for (c = 0; c < 8192; c++) {
            snprintf(ifname, sizeof(ifname), MACVTAP_NAME_PATTERN, c);
            if (ifaceGetIndex(false, ifname, &ifindex) == ENODEV) {
                rc = link_add(type, macaddress, 6, ifname, linkdev,
                              macvtapMode, &do_retry);
                if (rc == 0)
                    break;

                if (do_retry && --retries)
                    continue;
                return -1;
            }
        }
        cr_ifname = ifname;
    }

    if (vpAssociatePortProfileId(cr_ifname,
                                 macaddress,
                                 linkdev,
                                 virtPortProfile,
                                 vmuuid) != 0) {
        rc = -1;
        goto link_del_exit;
    }

    rc = ifaceUp(cr_ifname);
    if (rc != 0) {
        virReportSystemError(errno,
                             _("cannot 'up' interface %s -- another "
                             "macvtap device may be 'up' and have the same "
                             "MAC address"),
                             cr_ifname);
        rc = -1;
        goto disassociate_exit;
    }

    rc = openTap(cr_ifname, 10);

    if (rc >= 0) {
        if (configMacvtapTap(rc, vnet_hdr) < 0) {
            close(rc);
            rc = -1;
            goto disassociate_exit;
        }
        *res_ifname = strdup(cr_ifname);
    } else
        goto disassociate_exit;

    return rc;

disassociate_exit:
    vpDisassociatePortProfileId(cr_ifname,
                                macaddress,
                                linkdev,
                                virtPortProfile);

link_del_exit:
    link_del(cr_ifname);

    return rc;
}