Exemplo n.º 1
0
AsnInt setNetPrefix(VarBind *varbind, Variable *var)
{
  int cmp;
  NetPrefixNode *prefix, *newPrefix;
  AsnOid *varBindName;

  diag(COMPONENT,DIAG_DEBUG,"setNetPrefix");
  varBindName = &varbind->name;
  if(varbind->value->choiceId != OBJECTSYNTAX_SIMPLE ||
     varbind->value->a.simple->choiceId != SIMPLESYNTAX_NUMBER ||
     (varbind->value->a.simple->a.number != VALID && 
      varbind->value->a.simple->a.number != INVALID))
    return BADVALUE;
      
  if(AsnOidSize(varBindName) != NETPREFIX_LEN + INDEX_LEN ||
     varBindName->octs[NETPREFIX_LEN] != LOCALUNI || 
     varBindName->octs[NETPREFIX_LEN + 1] != NETPREFIX_STRINGLEN)
    return NOSUCHNAME;

  for(prefix = (NetPrefixNode *) var->value, cmp = AsnOidLess;
      prefix != NULL && (cmp = AsnOidCompare(varBindName, prefix->name)) <
	AsnOidEqual;
      prefix = prefix->next);

  if(varbind->value->a.simple->a.number == VALID && cmp != AsnOidEqual)
    {
      newPrefix = alloc_t(NetPrefixNode);
      newPrefix->name = alloc_t(AsnOid);
      newPrefix->name->octs = alloc(varBindName->octetLen);
      AsnOidCopy(newPrefix->name, varBindName);
{
      NetPrefixNode *tmp = (NetPrefixNode *) var->value;
      Q_INSERT_BEFORE(tmp, newPrefix, prefix);
}
      if(atmNetPrefix.octs == NULL)
	{
	  atmNetPrefix.octetLen = varBindName->octetLen - NETPREFIX_LEN - 2;
	  atmNetPrefix.octs = alloc(atmNetPrefix.octetLen);
	  memcpy(atmNetPrefix.octs, &varBindName->octs[NETPREFIX_LEN + 2], atmNetPrefix.octetLen);
	}
    }
  else if (varbind->value->a.simple->a.number == INVALID && cmp == AsnOidEqual)
    {
{
      NetPrefixNode *tmp = (NetPrefixNode *) var->value;
      Q_REMOVE(tmp, prefix);
}
    }

  return NOERROR;
}
Exemplo n.º 2
0
static int ioctl_set_pvc(ITF *itf,uint32_t ip,struct sockaddr_atmpvc *addr,
  const struct atm_qos *qos,int sndbuf,int flags)
{
    ENTRY *entry;
    VCC *vcc;
    int fd,result;

    if (lookup_ip(itf,ip)) return -EEXIST; 
    if ((fd = connect_vcc((struct sockaddr *) addr,qos,sndbuf,0)) < 0)
	return fd;
    if ((result = set_ip(fd,ip)) < 0) {
	do_close(fd);
	return result;
    }
    if (flags & ATF_NULL) {
	if ((result = set_encap(fd,0)) < 0) return result;
	flags |= ATF_PERM;
    }
    entry = alloc_entry(0);
    entry->state = as_valid;
    entry->ip = ip;
    entry->qos = *qos;
    entry->sndbuf = sndbuf;
    entry->flags = flags;
    entry->itf = itf;
    vcc = alloc_t(VCC);
    vcc->active = 1;
    vcc->connecting = 0;
    vcc->fd = fd;
    vcc->entry = entry;
    if (!(flags & ATF_PERM)) START_TIMER(entry,CREVAL);
    Q_INSERT_HEAD(entry->vccs,vcc);
    Q_INSERT_HEAD(itf->table,entry);
    return 0;
}
Exemplo n.º 3
0
mtimer_t *_mtimer_ustart( int32_t usec, 
                          void    (*callback)(void *user),
                          void    *user)
{
    mtimer_t *n,*walk,*last;

    n = alloc_t(mtimer_t);
    n->expiration.tv_usec = g_tnow.tv_usec+usec;
    n->expiration.tv_sec = g_tnow.tv_sec;
    n->callback = callback;
    n->user = user;
    while (n->expiration.tv_usec > 1000000) {
        n->expiration.tv_usec -= 1000000;
        n->expiration.tv_sec++;
    }
    last = NULL;
    for (walk = timers; walk; walk = walk->next)
        if (walk->expiration.tv_sec > n->expiration.tv_sec ||
          (walk->expiration.tv_sec == n->expiration.tv_sec &&
          walk->expiration.tv_usec > n->expiration.tv_usec)) break;
        else last = walk;
    if (walk) 
        Q_INSERT_BEFORE(timers,n,walk);
    else 
        Q_INSERT_AFTER(timers,n,last);
    return n;
}
Exemplo n.º 4
0
static int add_entry(struct sockaddr_atmpvc *from,struct sockaddr_atmpvc *to)
{
    LINK *l_from,*l_to;
    TABLE *entry;

    l_from = find_link(from->sap_addr.itf);
    l_to = find_link(to->sap_addr.itf);
    if (!l_from || !l_to) return -ENODEV;
    for (entry = l_from->table; entry; entry = entry->next)
	if (entry->in_vpi == from->sap_addr.vpi &&
	  (entry->in_vci == ATM_VCI_UNSPEC ||
	  from->sap_addr.vci == ATM_VCI_UNSPEC ||
	  entry->in_vci == from->sap_addr.vci)) return -EEXIST;
    entry = alloc_t(TABLE);
    entry->out = l_to;
    entry->in_vpi = from->sap_addr.vpi;
    entry->in_vci = from->sap_addr.vci;
    entry->out_vpi = to->sap_addr.vpi;
    entry->out_vci = to->sap_addr.vci;
    entry->next = l_from->table;
    l_from->table = entry;
    if (entry->in_vci == ATM_VCI_UNSPEC)
	diag(COMPONENT,DIAG_INFO,"added VP %d.%d -> %d.%d",l_from->id,
	  entry->in_vpi,l_to->id,entry->out_vpi);
    else diag(COMPONENT,DIAG_INFO,"added VC %d.%d.%d -> %d.%d.%d",l_from->id,
	  entry->in_vpi,entry->in_vci,l_to->id,entry->out_vpi,entry->out_vci);
    return 0;
}
Exemplo n.º 5
0
Msgs *create_msgs( void ){
	Msgs *m = alloc_t( Msgs );
	if( m == NULL ) return NULL;

	m->coldstart = create_coldstart_message();
	m->addrtable = create_va_getnext_message( 2,
		&atmfAddressStatus,
		&atmfSrvcRegTable );
	m->poll = create_getnext_message( atmfAddressTable );
	m->set = create_set_message();
	m->config = create_va_get_message( 6,
		&atmfAtmLayerUniVersion,
		&atmfAtmLayerMaxVpiBits,
		&atmfAtmLayerMaxVciBits,
		&atmfAtmLayerUniType,
		&atmfAtmLayerDeviceType,
		&atmfAddressRegistrationAdminStatus );
	m->apointmsg = create_va_get_message( 4,
		&atmfPortMyIdentifier,
		&atmfPortMyIfName,	/* some extra adjacency info */
		&atmfMySystemIdentifier,
		&sysUpTime );
	m->sysmsg = create_va_get_message( 7,
		&sysDescr,
		&sysObjectID,
		&sysUpTime,
		&sysContact,
		&sysName,
		&sysLocation,
		&sysServices );

	return m;
}
Exemplo n.º 6
0
void query_ip(const UN_CTX *ctx,uint32_t ip)
{
    ITF *itf;
    ENTRY *entry;
    NOTIFY *notifier;
    int result;

    diag(COMPONENT,DIAG_DEBUG,"query for %d.%d.%d.%d",
      ((unsigned char *) &ip)[0],((unsigned char *) &ip)[1],
      ((unsigned char *) &ip)[2],((unsigned char *) &ip)[3]);
    if (!(itf = lookup_itf_by_ip(ip))) {
	diag(COMPONENT,DIAG_WARN,"itf for %d.%d.%d.%d not found",
	    ((unsigned char *) &ip)[0],((unsigned char *) &ip)[1],
	    ((unsigned char *) &ip)[2],((unsigned char *) &ip)[3]);
	// brcm
	notify2(ctx,ip,NULL);
	return;
    }
    result = resolve(itf,ip,&entry,0);
    if (result < 0) {
	// brcm
	notify2(ctx,ip,NULL);
	return;
    }
    if (!result) {
	// brcm
	notify2(ctx,ip,entry);
	return;
    }
    notifier = alloc_t(NOTIFY);
    notifier->ctx = *ctx;
    notifier->next = entry->notify;
    entry->notify = notifier;
}
Exemplo n.º 7
0
void fab_init(CALL *call)
{
    FAB *fab;
    call->fab = alloc_t(FAB);
    fab = PRV(call);
    fab->active = 0;
    fab->next = calls;
    calls = call;
}
Exemplo n.º 8
0
BUFFER *buffer_create(int length,int key)
{
    BUFFER *buf;

    buf = alloc_t(BUFFER);
    buf->data = alloc(length);
    buf->length = length;
    buf->key = key;
    return buf;
}
Exemplo n.º 9
0
SIGNALING_ENTITY *sig_vc(const char *command,const char *path,int itf)
{
    SIGNALING_ENTITY *sig;

    sig = alloc_t(SIGNALING_ENTITY);
    sig->command = command;
    sig->path = path;
    sig->pvc.sap_addr.itf = -1;
    sig->itf = itf;
    sig->next = entities;
    entities = sig;
    return sig;
}
Exemplo n.º 10
0
static void connect_me(ENTRY *entry)
{
    VCC *vcc;
    int fd;

    assert(entry->addr->sas_family == AF_ATMSVC);
    if ((fd = connect_vcc((struct sockaddr *) entry->addr,&entry->qos,
      entry->sndbuf,CLIP_DEFAULT_IDLETIMER)) < 0) return;
    vcc = alloc_t(VCC);
    vcc->active = 1;
    vcc->connecting = 1;
    vcc->fd = fd;
    vcc->entry = entry;
    Q_INSERT_HEAD(entry->vccs,vcc);
}
Exemplo n.º 11
0
void add_route(SIG_ENTITY *sig,struct sockaddr_atmsvc *addr,int len)
{
    ROUTE *route;

    for (route = routes; route; route = route->next)
        if (route->len == len && (!len || atm_equal((struct sockaddr *) addr,
          (struct sockaddr *) &route->addr,len,
          AXE_PRVOPT | (len == INT_MAX ? 0 : AXE_WILDCARD))))
            diag(COMPONENT,DIAG_FATAL,"duplicate route");
    route = alloc_t(ROUTE);
    if (addr) route->addr = *addr;
    route->len = len;
    route->sig = sig;
    route->next = routes;
    routes = route;
}
Exemplo n.º 12
0
void enter_vpci(SIG_ENTITY *sig,int vpci,int itf)
{
    VPCI *entry;

    for (entry = sig->vpcis; entry; entry = entry->next)
	if (entry->vpci == vpci) {
	    diag(COMPONENT,DIAG_ERROR,"ignoring duplicate VPCI %d (itf %d)",
	      vpci,itf);
	    return;
	}
    entry = alloc_t(VPCI);
    entry->vpci = vpci;
    entry->itf = itf;
    entry->local_addr[0].state = ls_unused;
    entry->next = sig->vpcis;
    sig->vpcis = entry;
}
Exemplo n.º 13
0
void set_verbosity(const char *component,int level)
{
    COMPONENT *walk;

    if (!component) {
	default_verbosity = level;
	return;
    }
    for (walk = components; walk; walk = walk->next)
	if (!strcmp(walk->name,component)) break;
    if (!walk) {
	walk = alloc_t(COMPONENT);
	walk->name = component;
	walk->next = components;
	components = walk;
    }
    walk->verbosity = level;
}
Exemplo n.º 14
0
static int want_arp_srv(const ITF *itf)
{
    VCC *vcc;
    int fd;

    if (!itf->arp_srv) return -1;
    for (vcc = itf->arp_srv->vccs; vcc; vcc = vcc->next)
	if (!vcc->connecting) return 1;
    if (itf->arp_srv->vccs) return 0;
    if ((fd = connect_vcc((struct sockaddr *) itf->arp_srv->addr,
      &itf->arp_srv->qos,itf->arp_srv->sndbuf,CLIP_DEFAULT_IDLETIMER)) < 0)
	return 0;
    vcc = alloc_t(VCC);
    vcc->active = 1;
    vcc->connecting = 1;
    vcc->fd = fd;
    vcc->entry = itf->arp_srv;
    Q_INSERT_HEAD(itf->arp_srv->vccs,vcc);
    return 0;
}
Exemplo n.º 15
0
static void new_link(int sock,void *dummy)
{
    LINK *lnk;
    int fd;

    fd = accept(sock,NULL,NULL);
    if (fd < 0) {
	perror("accept");
	return;
    }
    lnk = alloc_t(LINK);
    lnk->state = id_none;
    lnk->id = -1;
    lnk->fd = fd;
    lnk->len = 0;
    lnk->table = NULL;
    lnk->next = links;
    links = lnk;
    dsp_fd_add(fd,new_data,lnk);
}
Exemplo n.º 16
0
SOCKET *new_sock(atm_kptr_t id)
{
    SOCKET *sock;
 
    sock = alloc_t(SOCKET);
    sock->sig = NULL;
    sock->state = ss_invalid;
    memset(&sock->pvc,0,sizeof(sock->pvc));
    sock->qos.txtp.traffic_class = sock->qos.rxtp.traffic_class = ATM_UBR;
    sock->id = id;
    memset(&sock->local,0,sizeof(sock->local));
    memset(&sock->remote,0,sizeof(sock->remote));
    memset(&sock->sap,0,sizeof(sock->sap));
    sock->error = 0;
    sock->call_state = cs_null;
    sock->ep_ref = -1;
    sock->conn_timer = NULL;
    sock->listen = NULL;
    sock->next = sockets;
    sockets = sock;
    return sock;
}
Exemplo n.º 17
0
mtimer_t *_mtimer_start( int32_t  sec,
                         void     (*callback)(void *arg),
                         void     *arg )
{
    mtimer_t *n, *walk, *last;

    n = alloc_t(mtimer_t);
    n->expiration.tv_usec = g_tnow.tv_usec;
    n->expiration.tv_sec  = g_tnow.tv_sec + sec;
    n->callback = callback;
    n->user = arg;

    last = NULL;
    for (walk = timers; walk; walk = walk->next)
        if (walk->expiration.tv_sec > n->expiration.tv_sec ||
            (walk->expiration.tv_sec == n->expiration.tv_sec &&
             walk->expiration.tv_usec > n->expiration.tv_usec)) break;
        else last = walk;
    if (walk) 
        Q_INSERT_BEFORE(timers,n,walk);
    else 
        Q_INSERT_AFTER(timers,n,last);
    return n;
}
Exemplo n.º 18
0
static void parser(FIELD *start,int level,int group)
{
    FIELD *walk;
    TAG *scan;
    VALUE_LIST *tag;
    int count,patch_here;
    BREAK *brk,*tmp_brks,*next;

    patch_here = 0; /* for gcc */
    for (walk = start; walk; walk = walk->next) {
	if (walk->structure) {
	    parser(walk->my_block,level,group);
	    continue;
	}
	if (walk->brk) {
	    code("%s%s\n","OP_IFEND","?");
	    brk = alloc_t(BREAK);
	    brk->pc = pc-1;
	    brk->next = brks;
	    brks = brk;
	}
	if (dump) {
	    if ((!walk->value || walk->value->type != vt_multi) && walk->size)
		code("%s%d\n","OP_DUMP",walk->seq);
	    if (walk->value || walk->name_list)
		to_dump("    { %d, dump_sym_%d, \"%s\" },\n",level,
		  walk->name_list ? walk->name_list->id : walk->seq,walk->id);
	    else to_dump("    { %d, NULL, \"%s\" },\n",level,walk->id);
        }
	if (!walk->value) {
	    if (walk->var_len != -1)
		code("%s%d%d%d/* %s */\n","OP_COPYVAR",walk->var_len,walk->pos,
		  walk->size/8,walk->id);
	    else if (*walk->id != '_' || walk->jump || dump)
		    code("%s%d%d%d/* %s */\n","OP_COPY",walk->jump,walk->pos,
		      walk->size,walk->id);
	}
	else switch (walk->value->type) {
		case vt_id:
		    if (*walk->id != '_' || walk->jump || dump)
			code("%s%d%d%d/* %s */\n","OP_COPY",walk->jump,
			  walk->pos,walk->size,walk->id);
		    break;
		case vt_multi:
		    code("%s%s/* %s */\n","OP_IFEND","?",walk->id);
		    walk->patch = pc-1;
		    if (dump) code("%s%d\n","OP_DUMP",walk->seq);
		    /* fall through */
		case vt_case:
		    if (*walk->id != '_' || dump)
			code("%s%d%d%d/* %s */\n","OP_COPY",0,walk->pos,
			  walk->size,walk->id); /* don't move */
		    count = 0;
		    for (scan = walk->value->tags; scan; scan = scan->next) {
			count++;
			for (tag = scan->more; tag; tag = tag->next) count++;
		    }
		    code("%s%d%d%d%d/* %s */\n","OP_CASE",walk->jump,
		      walk->pos,walk->size,count,walk->id);
		    for (scan = walk->value->tags; scan; scan = scan->next) {
			code("%s%d%s\n",scan->deflt ? "-1" : scan->value,
			  scan->group,"?");
			scan->patch = pc-1;
			for (tag = scan->more; tag; tag = tag->next) {
			    code("%s%d%s\n",tag->value,scan->group,"?");
			    tag->patch = pc-1;
			}
		    }
		    for (scan = walk->value->tags; scan; scan = scan->next) {
			patch(scan->patch,pc-scan->patch-1);
			for (tag = scan->more; tag; tag = tag->next)
			    patch(tag->patch,pc-tag->patch-1);
			if (!scan->block && scan->abort_id)
			    code("%s%s\n","OP_ABORT",scan->abort_id);
			parser(scan->block,level+1,scan->group);
			if (scan->next) {
			    code("%s%s\n","OP_JUMP","?");
			    scan->patch = pc-1;
			}
		    }
		    for (scan = walk->value->tags; scan && scan->next;
		      scan = scan->next)
			patch(scan->patch,pc-scan->patch-1);
		    if (walk->value->type == vt_multi) {
			code("%s%d\n","OP_JUMP",walk->patch-pc-3);
			patch(walk->patch,pc-walk->patch-1);
		    }
		    break;
		case vt_length:
		    code("%s%d%d%d/* %s */\n","OP_BEGIN_LEN",walk->jump,
                      walk->pos,walk->size,walk->id);
		    if (walk->value->recovery) {
			code("%s%s%d%d\n","OP_BEGIN_REC",walk->value->recovery,
			    group,"?");
			patch_here = pc-1;
		    }
		    tmp_brks = brks;
		    if (!walk->value->block && walk->value->abort_id) 
			code("%s%s\n","OP_ABORT",walk->value->abort_id);
		    parser(walk->value->block,level+1,group);
		    if (walk->value->recovery) {
			code("%s\n","OP_END_REC");
			patch(patch_here,pc);
		    }
		    for (brk = brks; brk; brk = next) {
			next = brk->next;
			patch(brk->pc,pc-brk->pc-1);
			free(brk);
		    }
		    brks = tmp_brks;
		    code("%s /* %s */\n","OP_END_LEN",walk->id);
		    break;
		default:
		    abort();
	    }
    }
}
Exemplo n.º 19
0
int main(int argc,char **argv)
{
    char *name,*config_file,*reboot_arg,*identify,*ident_opt,*new_root;
    char *uninst_dev;
    int query,more,version,uninstall,validate,do_md_install,pass;
    BOOT_SECTOR dummy;
    IMAGE_DESCR dummy2;
    struct stat st;
    int fd, md_fd;
    md_array_info_t md_array_info;
    md_disk_info_t md_disk_info;
    char md_boot_name[MAX_TOKEN+1];
    char md_boot_map[MAX_TOKEN+1];
    DT_ENTRY md_disk;
    DT_ENTRY *disk;

    config_file = DFL_CONFIG;
    reboot_arg = identify = ident_opt = new_root = uninst_dev = NULL;
    pass = do_md_install = query = version = uninstall = validate = 0;
    name = *argv++;
    argc--;
    cfg_init(cf_options);
    while (argc && **argv == '-') {
	argc--;
	if (argv[0][2]) usage(name);
	switch ((*argv++)[1]) {
	    case 'b':
		if (!argc) usage(name);
		cfg_set(cf_options,"boot",*argv++,NULL);
		argc--;
		break;
	    case 'c':
		cfg_set(cf_options,"compact",NULL,NULL);
		compact = 1;
		break;
	    case 'd':
		if (!argc) usage(name);
		cfg_set(cf_options,"delay",*argv++,NULL);
		argc--;
		break;
	    case 'D':
		if (!argc) usage(name);
		cfg_set(cf_options,"default",*argv++,NULL);
		argc--;
		break;
	    case 'f':
		if (!argc) usage(name);
		cfg_set(cf_options,"disktab",*argv++,NULL);
		argc--;
		break;
	    case 'l':
		cfg_set(cf_options,"linear",NULL,NULL);
		linear = 1;
		break;
	    case 'm':
		if (!argc) usage(name);
		cfg_set(cf_options,"map",*argv++,NULL);
		argc--;
		break;
	    case 'i':
		if (!argc) usage(name);
		cfg_set(cf_options,"install",*argv++,NULL);
		argc--;
		break;
	    case 'I':
		if (!argc) usage(name);
		identify = *argv++;
		if (--argc) {
		    ident_opt = *argv++;
		    argc--;
		}
		break;
	    case 'X':
		printf("-DIMAGES=%d -DCODE_START_1=%d -DCODE_START_2=%d "
		  "-DDESCR_SIZE=%d -DDSC_OFF=%d -DDSC_OFF2=%d -DDFCMD_OFF=%d "
		  "-DMSG_OFF=%d -DFLAGS_OFF=%d\n",MAX_IMAGES,
		  sizeof(BOOT_PARAMS_1),sizeof(BOOT_PARAMS_2),
		  sizeof(IMAGE_DESCR),
		  (void *) &dummy.par_1.descr[0]-(void *) &dummy,
		  (void *) &dummy.par_1.descr[1]-(void *) &dummy,
		  (void *) &dummy.par_1.descr[2]-(void *) &dummy,
		  (void *) &dummy.par_1.msg_len-(void *) &dummy,
		  (void *) &dummy2.flags-(void *) &dummy2);
		exit(0);
	    case 'C':
		if (!argc) usage(name);
		config_file = *argv++;
		argc--;
		break;
	    case 'S':
		if (!argc) usage(name);
		cfg_set(cf_options,"force-backup",*argv++,NULL);
		argc--;
		break;
	    case 's':
		if (!argc) usage(name);
		cfg_set(cf_options,"backup",*argv++,NULL);
		argc--;
		break;
	    case 'P':
		if (!argc) usage(name);
		if (!strcmp(*argv,"fix"))
		    cfg_set(cf_options,"fix-table",NULL,NULL);
		else if (!strcmp(*argv,"ignore"))
			cfg_set(cf_options,"ignore-table",NULL,NULL);
		    else usage(name);
		argv++;
		argc--;
		break;
	    case 'q':
		query = 1;
		break;
	    case 'r':
		if (!argc) usage(name);
		new_root = *argv++;
		argc--;
		break;
	    case 'R':
		if (!argc) reboot_arg = "";
		else while (argc) {
			if (!reboot_arg)
			    *(reboot_arg = alloc(strlen(*argv)+1)) = 0;
			else strcat(reboot_arg = ralloc(reboot_arg,
			      strlen(reboot_arg)+strlen(*argv)+2)," ");
			strcat(reboot_arg,*argv++);
			argc--;
		    }
		break;
	    case 't':
		test = 1;
		break;
	    case 'u':
		validate = 1;
		/* fall through */
	    case 'U':
		uninstall = 1;
		if (argc) {
		    if (argc-- > 1) usage(name);
		    uninst_dev = *argv;
		}
		break;
	    case 'v':
		verbose++;
		break;
	    case 'V':
		version = 1;
		break;
	    case 'w':
		cfg_set(cf_options,"nowarn",NULL,NULL);
		nowarn = 1;
		break;
	    default:
		usage(name);
	}
    }
    if (!new_root) new_root = getenv("ROOT");
    if (new_root && *new_root) {
	if (chroot(new_root) < 0) die("chroot %s: %s",new_root,strerror(errno));
	if (chdir("/") < 0) die("chdir /: %s",strerror(errno));
    }
    if (atexit(temp_remove)) die("atexit() failed");
    if (verbose > 0 || version) {
	printf("LILO version 21%s",version ? "\n" : "");
	if (version) return 0;
	printf(", Copyright 1992-1998 Werner Almesberger\n\n");
    }
#if 0
    if (((install || test || boot_device || disktab_file || compact) && !argc)
      || (compact && linear && 0)) usage(name);
#endif
    if (!nowarn && compact && linear)
	fprintf(stderr,"Warning: COMPACT may conflict with LINEAR on some "
	  "systems\n");
    preload_types();
    fd = cfg_open(config_file);
    more = cfg_parse(cf_options);
    if (!nowarn) {
	if (fstat(fd,&st) < 0) {
	    fprintf(stderr,"fstat %s: %s\n",config_file,strerror(errno));
	    exit(1);
	}
	if (S_ISREG(st.st_mode)) {
	    if (st.st_uid)
		fprintf(stderr,"Warning: %s should be owned by root\n",
		  config_file);
	    else if (st.st_mode & (S_IWGRP | S_IWOTH))
		    fprintf(stderr,"Warning: %s should be writable only for "
		      "root\n",config_file);
		else if ((cfg_get_strg(cf_all,"password") || cfg_get_strg(
		      cf_options,"password")) && (st.st_mode & (S_IRGRP |
		      S_IROTH)))
			fprintf(stderr,"Warning: %s should be readable only "
			  "for root if using PASSWORD\n",config_file);
	}
    }
    preload_dev_cache();
    if (identify) identify_image(identify,ident_opt);
    if (strncmp("/dev/md",cfg_get_strg(cf_options,"boot"),7) == 0) {
	if ((md_fd=open(cfg_get_strg(cf_options,"boot"),O_NOACCESS)) < 0)
	    die("Unable to open %s",cfg_get_strg(cf_options,"boot"));
	if (fstat(md_fd,&st) < 0)
	    die("Unable to stat %s",cfg_get_strg(cf_options,"boot"));
	if (!S_ISBLK(st.st_mode))
	    die("%s is not a block device",cfg_get_strg(cf_options,"boot"));
	if (ioctl(md_fd,GET_ARRAY_INFO,&md_array_info) < 0)
	    die("Unable to get RAID info on %s",cfg_get_strg(cf_options,"boot"));
	if ((md_array_info.major_version == 0) && (md_array_info.minor_version < 90))
	    die("Raid versions < 0.90 are not supported");
	if (md_array_info.level != 1)
	    die("Only RAID1 devices are supported as boot devices");
	do_md_install = 1;
	strcpy(md_boot_name,cfg_get_strg(cf_options,"boot"));
	if (cfg_get_strg(cf_options,"map"))
	    strcpy(md_boot_map,cfg_get_strg(cf_options,"map"));
	else
	    strcpy(md_boot_map,MAP_FILE);
	md_disk.device = (MD_MAJOR << 8) | md_array_info.md_minor;
	md_disk.bios = 0x80;
	md_disk.next = disktab;
	disktab = &md_disk;
    }
    while( (pass == 0) || (do_md_install && (pass < md_array_info.nr_disks)) ) {
	if(do_md_install) {
	    GEOMETRY geo;
	    DEVICE dev;
	    int device,disk_fd;
	    char new_name[MAX_TOKEN+1];

	    if(pass > 0) {
		close(fd);
		cfg_init(cf_options);
		fd = cfg_open(config_file);
		more = cfg_parse(cf_options);
	    }
	    md_disk_info.number = pass;
	    if (ioctl(md_fd,GET_DISK_INFO,&md_disk_info) < 0)
		die("main: GET_DISK_INFO: %s", strerror(errno));
	    device = (md_disk_info.major << 8) | md_disk_info.minor;
	    disk_fd = dev_open(&dev,device,O_NOACCESS);
	    if (md_disk_info.state == MD_DISK_FAULTY) {
		printf("disk %s marked as faulty, skipping\n",dev.name);
		pass++;
		continue;
	    }
	    geo_query_dev(&geo,device,1);
	    disk = alloc_t(DT_ENTRY);
	    disk->bios = 0x80;
	    disk->device = device & 0xfff0;
	    disk->sectors = geo.sectors;
	    disk->heads = geo.heads;
	    disk->cylinders = geo.cylinders;
	    disk->start = geo.start;
	    disk->next = disktab;
	    disktab = disk;
	    if (cfg_get_strg(cf_options,"boot")) cfg_unset(cf_options,"boot");
	    if (cfg_get_strg(cf_options,"map")) cfg_unset(cf_options,"map");
	    strncpy(new_name,dev.name,8);
	    new_name[8] = '\0';
	    cfg_set(cf_options,"boot",new_name,NULL);
	    snprintf(new_name,MAX_TOKEN,"%s.%04x",md_boot_map,device);
	    cfg_set(cf_options,"map",new_name,NULL);
	    printf("boot = %s, map = %s\n", cfg_get_strg(cf_options,"boot"),
		cfg_get_strg(cf_options,"map"));
	    md_disk.sectors = geo.sectors;
	    md_disk.heads = geo.heads;
	    md_disk.cylinders = geo.cylinders;
	    md_disk.start = geo.start;
	}
	    
	pass++;
	if (uninstall)
	    bsect_uninstall(uninst_dev ? uninst_dev : cfg_get_strg(cf_options,
	      "boot"),cfg_get_strg(cf_options,"backup"),validate);
	compact = cfg_get_flag(cf_options,"compact");
	linear = cfg_get_flag(cf_options,"linear");
	nowarn = cfg_get_flag(cf_options,"nowarn");
	if (cfg_get_strg(cf_options,"verbose"))
	    verbose += to_number(cfg_get_strg(cf_options,"verbose"));
	if (reboot_arg) {
	    map_patch_first(cfg_get_strg(cf_options,"map") ? cfg_get_strg(
	      cf_options,"map") : MAP_FILE,reboot_arg);
	    exit(0);
	}
	if (argc) usage(name);
	geo_init(cfg_get_strg(cf_options,"disktab"));
	if (query)
	    show_images(!cfg_get_strg(cf_options,"map") ? MAP_FILE :
	      cfg_get_strg(cf_options,"map"));
	bsect_open(cfg_get_strg(cf_options,"boot"),cfg_get_strg(cf_options,"map") ?
	  cfg_get_strg(cf_options,"map") : MAP_FILE,cfg_get_strg(cf_options,
	  "install"),cfg_get_strg(cf_options,"delay") ? to_number(cfg_get_strg(
	  cf_options,"delay")) : 0,cfg_get_strg(cf_options,"timeout") ?
	  to_number(cfg_get_strg(cf_options,"timeout")) : -1);
	if (more) {
            cfg_init(cf_top);
            if (cfg_parse(cf_top)) cfg_error("Syntax error");
	}
	if (!bsect_number()) die("No images have been defined.");
	check_fallback();
	if (!test)
	    if (cfg_get_strg(cf_options,"force-backup"))
		bsect_update(cfg_get_strg(cf_options,"force-backup"),1);
	    else bsect_update(cfg_get_strg(cf_options,"backup"),0);
	else {
	    bsect_cancel();
	    fprintf(stderr,"The boot sector and the map file have *NOT* been "
	      "altered.\n");
	}
    }
    return 0;
}
Exemplo n.º 20
0
 MyVec()
     : arena_t{}, vector_t{alloc_t(static_cast<arena_t &>(*this))}
 {
     vector_t::reserve(NUM_EL); // set up the std::vector to use the entire arena!!!
     assert(vector_t::capacity() == NUM_EL);
 }
Exemplo n.º 21
0
Arquivo: io.c Projeto: ebichu/dd-wrt
static void accept_new(void)
{
    char buffer[MAX_ATM_ADDR_LEN+1];
    struct sockaddr_atmsvc addr;
    struct atm_qos qos;
    ENTRY *entry;
    VCC *vcc;
    int fd,error;
    socklen_t len,size;

    len = sizeof(addr);
    if ((fd = accept(incoming,(struct sockaddr *) &addr,&len)) < 0) {
	error = errno;
	diag(COMPONENT,DIAG_ERROR,"accept: %s",strerror(errno));
	if (error == EUNATCH) {
	    diag(COMPONENT,DIAG_WARN,"disabling SVCs");
	    (void) close(incoming);
	    incoming = -1;
	}
	return;
    }
    /* the following code probably belongs to arp.c ... */
    if (atm2text(buffer,MAX_ATM_ADDR_LEN+1,(struct sockaddr *) &addr,pretty) <
      0) strcpy(buffer,"<atm2text error>");
    diag(COMPONENT,DIAG_DEBUG,"Incoming call from %s",buffer);
    size = sizeof(qos);
    if (getsockopt(fd,SOL_ATM,SO_ATMQOS,&qos,&size) < 0)
	diag(COMPONENT,DIAG_FATAL,"getsockopt SO_ATMQOS: %s",strerror(errno));
    if (size != sizeof(qos))
	diag(COMPONENT,DIAG_FATAL,"SO_ATMQOS: size %d != %d",size,sizeof(qos));
    if (ioctl(fd,ATMARP_MKIP,qos.txtp.traffic_class == ATM_NONE ? 0 :
      CLIP_DEFAULT_IDLETIMER) < 0) {
        diag(COMPONENT,DIAG_ERROR,"ioctl ATMARP_MKIP: %s",strerror(errno));
        (void) do_close(fd);
        return;
    }
    vcc = alloc_t(VCC);
    vcc->active = 0;
    vcc->connecting = 0;
    vcc->fd = fd;
    if (qos.txtp.traffic_class == ATM_NONE) {
	vcc->entry = NULL;
	incoming_unidirectional(vcc);
	Q_INSERT_HEAD(unidirectional_vccs,vcc);
	return;
    }
    if (merge) {
	ITF *itf;

	for (itf = itfs; itf; itf = itf->next) {
	    entry = lookup_addr(itf,&addr);
	    if (entry) {
		vcc->entry = entry;
		Q_INSERT_HEAD(entry->vccs,vcc);
		if (entry->state == as_valid) {
		    if (set_ip(vcc->fd,entry->ip) < 0) {
			diag(COMPONENT,DIAG_ERROR,"set_ip: %s",
			  strerror(errno));
			disconnect_vcc(vcc);
		    }
		    else set_sndbuf(vcc);
		}
		return;
	    }
	}
    }
    entry = alloc_entry(1);
    entry->state = as_invalid;
    entry->addr = alloc_t(struct sockaddr_atmsvc);
    *entry->addr = addr;
    entry->flags = ATF_PUBL;
    Q_INSERT_HEAD(unknown_incoming,entry);
    vcc->entry = entry;
    Q_INSERT_HEAD(entry->vccs,vcc);
    incoming_call(vcc);
}