コード例 #1
0
ファイル: pvc2684d.c プロジェクト: TheTypoMaster/AH4222
// brcm
int delete_br(int num)
//int delete_br(char *nstr)
{
//  int num, err;
  int err;
  int sock;

  sock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
  if (sock<0) {
    syslog(LOG_ERR, "socket creation failed: %s",strerror(errno));
  } else {
    /* create the device with ioctl: */
    //num=atoi(nstr);
    if( num>=0 && num<1234567890){
      struct atm_newif_br2684 ni;
      ni.backend_num = ATM_BACKEND_BR2684;
      ni.media = BR2684_MEDIA_ETHERNET;
      ni.mtu = 1500;
      setIndexName(ni.ifname, "nas", num);
      //sprintf(ni.ifname, "nas_%d", num);
      err=ioctl (sock, BR2684_DEL, &ni);
    } else {
      syslog(LOG_ERR,"err: strange interface number %d", num );
    }
  }
  return 0;
}
コード例 #2
0
ファイル: CreateIndex.cpp プロジェクト: mtin/hyrise
std::shared_ptr<PlanOperation> CreateIndex::parse(const Json::Value &data) {
  auto i = BasicParser<CreateIndex>::parse(data);
  i->setIndexName(data["index_name"].asString());

  if (data.isMember("index_type"))
    i->setIndexType(data["index_type"].asString());

  if (data.isMember("page_size"))
    i->setIndexPageSize(data["page_size"].asInt());
  else
    i->setIndexPageSize(-1);

  return i;
}
コード例 #3
0
static int assign_vcc_for_bcm_intf(struct sockaddr_atmpvc addr, int nas_idx,
    int encap, int bufsize, int proto_filter, int mode, unsigned short  vlan_id)
{
    int fd = -1;

    if( (fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) >= 0 )
    {
        struct atm_backend_br2684 be;
        int portId = GET_NAS_IDX_PORT(nas_idx);
        int vpi = GET_NAS_IDX_VPI(nas_idx);
        int vci = GET_NAS_IDX_VCI(nas_idx);

        be.backend_num   = ATM_BACKEND_BR2684_BCM;
        be.ifspec.method = BR2684_FIND_BYIFNAME;
        setIndexName(be.ifspec.spec.ifname, "nas", nas_idx);
        be.fcs_in        = BR2684_FCSIN_NO;
        be.fcs_out       = BR2684_FCSOUT_NO;
        be.fcs_auto      = 0;
        be.encaps        = encap;
        be.has_vpiid     = (portId << 28) | (vpi << 16) | vci;
        be.send_padding  = 0;
        be.min_size      = 0;
        be.proto_filter  = proto_filter;
        be.vlan_id       = vlan_id;
        be.extif         = 0;

        if( ioctl (fd, ATM_SETBACKEND, &be) == 0 )
        {
            do_error(LOG_INFO,"Communicating over ATM %d.%d.%d, encapsulation: "
                "LLC\n", portId, vpi, vci);
        }
        else
        {
            do_error(LOG_WARNING,"Could not configure interface:%s\n",
                strerror(errno));
            close(fd);
            fd = -1;
        }
    }
    else
    {
        do_error(LOG_WARNING,"failed to create socket, reason: %s",
            strerror(errno));
    }

    return( fd );
}
コード例 #4
0
static int assign_vcc_filter_for_intf(struct sockaddr_atmpvc addr, int nas_idx,
                                            int extif, int proto_filter)
{
    int fd = -1;

    if( (fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) >= 0 )
    {
        struct atm_backend_br2684 be;
        int portId = GET_NAS_IDX_PORT(nas_idx);
        int vpi = GET_NAS_IDX_VPI(nas_idx);
        int vci = GET_NAS_IDX_VCI(nas_idx);

        //bzero(&be, sizeof(struct atm_backend_br2684));
        be.backend_num   = ATM_BACKEND_BR2684_BCM;
        be.ifspec.method = BR2684_FIND_BYIFNAME;
        setIndexName(be.ifspec.spec.ifname, "nas", nas_idx);
        //sprintf(be.ifspec.spec.ifname, "%s_%d_%d_%d","nas",vpi,vci,extif);
        be.has_vpiid = extif;
        be.proto_filter  = proto_filter;
        be.extif     = extif;

        if( ioctl (fd, ATM_SETEXTFILT, &be) == 0 )
        {
            do_error(LOG_INFO,"Communicating over ATM %d.%d.%d, encapsulation: "
                "LLC\n", portId, vpi, vci);
        }
        else
        {
            do_error(LOG_WARNING,"Could not configure interface:%s\n",
                strerror(errno));
            close(fd);
            fd = -1;
        }
    }
    else
    {
        do_error(LOG_WARNING,"failed to create socket, reason: %s",
            strerror(errno));
    }

    return( fd );
}
コード例 #5
0
ファイル: pvc2684d.c プロジェクト: TheTypoMaster/AH4222
// brcm
int create_br(int nas_idx, int mode)
//int create_br(int nas_idx)
{
  int sock, result = 0;
  struct atm_newif_br2684 ni;
  // brcm
  struct atm_newif_rt2684 ni_rt;
  int ret = 0;

  if((sock = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) < 0)

    do_error(LOG_WARNING, "socket creation failed for nas%d: %s",nas_idx,strerror(errno));

  else {
    
    /* Create the the bridge-encapsulation interface.
     */
    // brcm
    if (!mode) {
        ni.backend_num = ATM_BACKEND_BR2684;
        ni.media       = BR2684_MEDIA_ETHERNET;
	ni.mtu         = 1500;
	// brcm
        setIndexName(ni.ifname, "nas", nas_idx);
        //sprintf(ni.ifname, "nas_%d", nas_idx);
    } else {
        ni_rt.backend_num = ATM_BACKEND_RT2684;
	// brcm
        setIndexName(ni_rt.ifname, "ipa", nas_idx);
        //sprintf(ni_rt.ifname, "atm_%d", nas_idx);
    }
    // brcm
    /*
    ni.backend_num = ATM_BACKEND_BR2684;
    ni.media       = BR2684_MEDIA_ETHERNET;
    ni.mtu         = 1500;
    sprintf(ni.ifname, "nas%d", nas_idx);
    */
    // brcm
    if (!mode)
        ret=ioctl (sock, ATM_NEWBACKENDIF, &ni);
    else
        ret=ioctl (sock, ATM_NEWBACKENDIF, &ni_rt);
    if (ret < 0) {
      
      if(errno == EEXIST) {

	/* It's not fatal to create an interface that already exists.
	   We probably will end up doing it all the time because there's
	   no way to delete interfaces. Not a problem.
	*/
	/*	do_error(LOG_INFO, "Interface %s already exists", ni.ifname);  */
	result = 1;

      } else
	do_error(LOG_WARNING, "Can't create interface : %s", strerror(errno));
    } else {

      do_error(LOG_INFO, "Interface \"%s\" created sucessfully\n",mode? ni_rt.ifname:ni.ifname);
      result = 1;
    }
  }
  close(sock);
  return result;
}
コード例 #6
0
ファイル: pvc2684d.c プロジェクト: TheTypoMaster/AH4222
// brcm
int assign_vcc(struct sockaddr_atmpvc addr, int nas_idx, int encap, int bufsize, int proto_filter, int mode)
//int assign_vcc(struct sockaddr_atmpvc addr, int nas_idx, int encap, int bufsize)
{
  int fd;
  struct atm_qos qos;
  struct atm_backend_br2684 be;
  // brcm
  struct atm_backend_rt2684 be_rt;
  int ret=0;

  if ((fd = socket(PF_ATMPVC, SOCK_DGRAM, ATM_AAL5)) < 0) {
    do_error(LOG_WARNING,"failed to create socket, reason: %s", strerror(errno));
    return -1;
  }
  
  memset(&qos, 0, sizeof(qos));
  qos.aal                     = ATM_AAL5;
  qos.txtp.traffic_class      = ATM_UBR;
  qos.txtp.max_sdu            = 1524;
  qos.txtp.pcr                = ATM_MAX_PCR;
  qos.rxtp = qos.txtp;
    
  if( setsockopt(fd,SOL_SOCKET,SO_SNDBUF, &bufsize ,sizeof(bufsize)) < 0) {
    do_error(LOG_WARNING,"setsockopt SO_SNDBUF: (%d) %s\n",bufsize, strerror(errno));
    return -1;
  }

  if( setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0) {
    do_error(LOG_WARNING,"setsockopt SO_ATMQOS %s", strerror(errno));
    return -1;
  }

  if( connect(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_atmpvc)) < 0) {
    do_error(LOG_WARNING,"failed to connect on socket: %s", strerror(errno));
    return -1;
  }
  
  /* attach the vcc to device.
   */
  // brcm
  if (!mode) {
  // brcm
  be.backend_num   = ATM_BACKEND_BR2684;
  be.ifspec.method = BR2684_FIND_BYIFNAME;
  // brcm
  setIndexName(be.ifspec.spec.ifname, "nas", nas_idx);
  //sprintf(be.ifspec.spec.ifname, "nas_%d", nas_idx);
  be.fcs_in        = BR2684_FCSIN_NO;
  be.fcs_out       = BR2684_FCSOUT_NO;
  be.fcs_auto      = 0;
  be.encaps        = encap;
  be.has_vpiid     = 0;
  be.send_padding  = 0;
  be.min_size      = 0;
  // brcm
  be.proto_filter  = proto_filter;

  // brcm
  } else {
    be_rt.backend_num   = ATM_BACKEND_RT2684;
    be_rt.ifspec.method = BR2684_FIND_BYIFNAME;
    // brcm
    setIndexName(be_rt.ifspec.spec.ifname, "ipa", nas_idx);
    //sprintf(be_rt.ifspec.spec.ifname, "atm_%d", nas_idx);
    be_rt.encaps        = encap;
  }

  // brcm
  if (!mode)
      ret = ioctl (fd, ATM_SETBACKEND, &be);
  else
      ret = ioctl (fd, ATM_SETBACKEND, &be_rt);
  if( ret == 0) {
    do_error(LOG_INFO,"Communicating over ATM %d.%d.%d, encapsulation: %s\n", 
	     addr.sap_addr.itf,
	     addr.sap_addr.vpi,
	     addr.sap_addr.vci,
	     encap ? "LLC" : "VC mux");
    return fd;
  } else {
    do_error(LOG_WARNING,"Could not configure interface:%s",strerror(errno));
    return -1;
  }
}
コード例 #7
0
ファイル: CreateIndex.cpp プロジェクト: HanumathRao/hyrise
std::shared_ptr<PlanOperation> CreateIndex::parse(const Json::Value& data) {
  auto i = BasicParser<CreateIndex>::parse(data);
  i->setIndexName(data["index_name"].asString());
  return i;
}