Exemple #1
0
SimpleSSEServer::SimpleSSEServer(const Settings& settings):
    BaseServer_<SimpleSSEServerSettings, SimpleSessionStore>(settings),
    _fileSystemRoute(settings.fileSystemRouteSettings),
    _sseRoute(settings.sseRouteSettings)
{
    addRoute(&_fileSystemRoute);
    addRoute(&_sseRoute);
}
Exemple #2
0
SimpleIPVideoServer::SimpleIPVideoServer(const Settings& settings):
    BaseServer_<SimpleIPVideoServerSettings, SimpleSessionStore>(settings),
    _fileSystemRoute(settings.fileSystemRouteSettings),
    _postRoute(settings.postRouteSettings),
    _ipVideoRoute(settings.ipVideoRouteSettings)
{
    addRoute(&_fileSystemRoute);
    addRoute(&_postRoute);
    addRoute(&_ipVideoRoute);
}
Exemple #3
0
settings_controller::settings_controller(boost::shared_ptr<session_manager_interface> session, nscapi::core_wrapper* core, unsigned int plugin_id)
  : session(session)
  , core(core)
  , plugin_id(plugin_id)
  , RegexpController("/api/v1/settings")
{
	addRoute("GET", "(/)$", this, &settings_controller::get_section);
	addRoute("GET", "(/.+)/$", this, &settings_controller::get_section);
	addRoute("GET", "(/.+)/(.+)$", this, &settings_controller::get_key);
}
Exemple #4
0
void
setupInterface(nvlist_t *data)
{
    char *iface, *gateway, *netmask, *ip;
    boolean_t primary;
    int ret;

    ret = nvlist_lookup_string(data, "interface", &iface);
    if (ret == 0) {
        plumbIf(iface);

        ret = nvlist_lookup_string(data, "ip", &ip);
        if (ret == 0) {
            ret = nvlist_lookup_string(data, "netmask", &netmask);
            if (ret == 0) {
                if (raiseIf(iface, ip, netmask) != 0) {
                    fatal(ERR_RAISE_IF, "Error bringing up interface %s",
                        iface);
                }
            }
            ret = nvlist_lookup_boolean_value(data, "primary", &primary);
            if ((ret == 0) && (primary == B_TRUE)) {
                ret = nvlist_lookup_string(data, "gateway", &gateway);
                if (ret == 0) {
                    (void) addRoute(iface, gateway, "0.0.0.0", 0);
                }
            }
        }
    }
}
Exemple #5
0
QList<PathItem *> PathView::loadData(const Data &data)
{
	QList<PathItem *> paths;
	int zoom = _zoom;


	for (int i = 0; i < data.tracks().count(); i++)
		paths.append(addTrack(*(data.tracks().at(i))));
	for (int i = 0; i < data.routes().count(); i++)
		paths.append(addRoute(*(data.routes().at(i))));
	addWaypoints(data.waypoints());

	if (_tracks.empty() && _routes.empty() && _waypoints.empty())
		return paths;

	if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
	  || (_waypoints.size() && _zoom < zoom))
		rescale(_zoom);
	else
		updatePOIVisibility();

	QRectF sr = contentsSceneRect();
	_scene->setSceneRect(sr);
	centerOn(sr.center());

	_mapScale->setZoom(_zoom, -(sr.center().ry() * mapScale(_zoom)));
	if (_mapScale->scene() != _scene)
		_scene->addItem(_mapScale);

	return paths;
}
Exemple #6
0
void MainWindow::addRouteClicked()
{
    ui->routesView->setColumnWidth(0, 170);
    ui->routesView->setColumnWidth(1, 40);
   // std::cout << "points:" << qPrintable(ui->fromLineEdit->text()) << " " << qPrintable(ui->toLineEdit->text())<< std::endl;
    emit addRoute(ui->fromLineEdit->text(), ui->toLineEdit->text());
}
Exemple #7
0
GvBool 
GvScene::addRoute(GvNode * from, int fromIndex, GvNode * to,int toIndex)
{
    GvRoute *route = new GvRoute();
    route->set(from,fromIndex,to,toIndex);
    return addRoute(route,FALSE);
}
Exemple #8
0
static int
setupStaticRoute(nvlist_t *route, const char *idx)
{
    boolean_t linklocal = B_FALSE;
    char *slash;
    char *dstraw = NULL;
    char *dst;
    char *gateway;
    int dstpfx = -1;
    int ret = -1;

    if (nvlist_lookup_boolean_value(route, "linklocal", &linklocal) == 0 &&
      linklocal) {
        WARNLOG("route[%s]: linklocal routes not supported", idx);
        goto bail;
    }

    if (nvlist_lookup_string(route, "dst", &dst) != 0) {
        WARNLOG("route[%s]: route is missing \"dst\"", idx);
        goto bail;
    }

    if (nvlist_lookup_string(route, "gateway", &gateway) != 0) {
        WARNLOG("route[%s]: route is missing \"gateway\"", idx);
        goto bail;
    }

    /*
     * Parse the CIDR-notation destination specification.  For example:
     * "172.20.5.1/24" becomes a destination of "172.20.5.1" with a prefix
     * length of 24.
     */
    if ((dstraw = strdup(dst)) == NULL) {
        WARNLOG("route[%s]: strdup failure", idx);
        goto bail;
    }

    if ((slash = strchr(dstraw, '/')) == NULL) {
        WARNLOG("route[%s]: dst \"%s\" invalid", idx, dst);
        goto bail;
    }
    *slash = '\0';
    dstpfx = atoi(slash + 1);
    if (dstpfx < 0 || dstpfx > 32) {
        WARNLOG("route[%s]: dst \"%s\" pfx %d invalid", idx, dst, dstpfx);
        goto bail;
    }

    if ((ret = addRoute(NULL, gateway, dstraw, dstpfx)) != 0) {
        WARNLOG("route[%s]: failed to add (%d)", idx, ret);
        goto bail;
    }

    ret = 0;

bail:
    free(dstraw);
    return (ret);
}
Exemple #9
0
/**
 * The default configurations for the Firestudio Tube.
 * 82 destinations; each "group" every 32 registers
 **FIXME What follows is extracted from a listing of an existing router configuration.
 *       However, the origin of such a router configuration was unknown.
 */
void
FirestudioTube::FirestudioTubeEAP::setupDefaultRouterConfig_low() {
    unsigned int i;
    // the 1394 stream receivers
    for (i=0; i<16; i++) {
        addRoute(eRS_InS0, i, eRD_ATX0, i);
    }
    // Then 16 muted destinations
    for (i=0; i<16; i++) {
        addRoute(eRS_Muted, 0, eRD_Muted, 0);
    }
    
    // the Mixer inputs
    for (i=0; i<16; i++) {
        addRoute(eRS_InS0, i, eRD_Mixer0, i);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_ARX0, i, eRD_Mixer1, i);
    }
    // Then 14 muted destinations
    for (i=0; i<14; i++) {
        addRoute(eRS_Muted, 0, eRD_Muted, 0);
    }

    // The audio ports
    // Ensure that audio port are not muted
    for (i=0; i<8; i++) {
        addRoute(eRS_ARX0, i, eRD_InS0, i);
    }
    // Then 10 muted destinations
    for (i=0; i<10; i++) {
        addRoute(eRS_Muted, 0, eRD_Muted, 0);
    }  
}
Exemple #10
0
RequestRouter::RequestRouter(IUidRestService *service, QObject *parent)
    : QObject(parent),
      m_service(service),
      m_restService(NULL),
      m_uidRestService(service),
      m_hasDefaultRoute(false)
{
    addRoute("/")
            ->on(IRequest::GET, ROUTE(m_uidRestService->index))
            ->on(IRequest::POST, ROUTE(m_uidRestService->create));

    addRoute("/:id")
            ->on(IRequest::GET, ROUTE(m_uidRestService->show, STR(id) ))
            ->on(IRequest::PUT, ROUTE(m_uidRestService->edit, STR(id) ))
            ->on(IRequest::DELETE, ROUTE(m_uidRestService->del, STR(id) ));

    service->init(this);
}
void DFS(TreeNode* root, int sum, Result* res, Route* route) {
    if (sum == root->val) {
        if (!root->left && !root->right) {
            addRoute(route, root->val);
            newColumn(res, route);
            route->size -= 1;
        } else {
            addRoute(route, root->val);
            if (root->left) DFS(root->left, sum - root->val, res, route);
            if (root->right) DFS(root->right, sum - root->val, res, route);
            route->size -= 1;
        }
    } else {
        addRoute(route, root->val);
        if (root->left) DFS(root->left, sum - root->val, res, route);
        if (root->right) DFS(root->right, sum - root->val, res, route);
        route->size -= 1;
    }
}
		TITANIUM_FUNCTION(View, addRoute)
		{
			TITANIUM_ASSERT(arguments.size() == 1);

			auto _0 = arguments.at(0);
			TITANIUM_ASSERT(_0.IsObject());
			addRoute(static_cast<JSObject>(_0).GetPrivate<Route>());
			
			return get_context().CreateUndefined();
		}
Exemple #13
0
void MapBox::calcRoute()
{
    if (m_markerObjects.count() < 2)
        return;

    QList<QGeoCoordinate> waypoints;

    for (int i = 0; i < m_markerObjects.count(); i++) {
        QGeoMapPixmapObject * p = m_markerObjects.at(i);
        waypoints.append(p->coordinate());
    }

    addRoute(waypoints);
}
Exemple #14
0
AudioPortConfig::AudioPortConfig(QWidget* parent)
: QFrame(parent)
{
    setupUi(this);
    _selected = 0;
    selectedIndex = -1;
    connect(routeList, SIGNAL(itemSelectionChanged()), SLOT(routeSelectionChanged()));
    connect(newSrcList, SIGNAL(itemSelectionChanged()), SLOT(srcSelectionChanged()));
    connect(newDstList, SIGNAL(itemSelectionChanged()), SLOT(dstSelectionChanged()));
    connect(tracksList, SIGNAL(itemSelectionChanged()), SLOT(trackSelectionChanged()));
    connect(removeButton, SIGNAL(clicked()), SLOT(removeRoute()));
    connect(connectButton, SIGNAL(clicked()), SLOT(addRoute()));
    connect(btnConnectOut, SIGNAL(clicked()), SLOT(addOutRoute()));
    connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
    routingChanged();
}
//初始化,构建整个图
//从文件读取
SubwayGuider &SubwayGuider::init(string fileName) {
    //键为几号线
    //值为该线上的站点
    map<int, vector<tmp>> tmpMap;
    struct tmp t;

    ifstream inFile(fileName);
    while (!inFile.eof()) {
        int line, stopNum;
        inFile >> line >> stopNum;
        while (stopNum--) {
            inFile >> t.name >> t.price >> t.time;
            t.line = line;
            //尚无当前站点
            if (subwayMap.find(t.name) == subwayMap.end()) {
                //添加新站点
                subwayMap[t.name] = HeadNode(t.name, line);
            } else {
                //已经有了当前站点
                //为站点添加新线路信息(没什么用
                subwayMap[t.name].linePassThisStop.push_back(line);
            }
            tmpMap[line].push_back(t);
        }
    }
    inFile.close();

    //创建线路
    for (const auto &item : tmpMap) {
        for (auto cur = item.second.begin(); cur != item.second.end() - 1; cur++) {
            addRoute(*cur, (cur + 1)->name);
        }
    }

    createMap();
    return *this;
}
Exemple #16
0
void LoginController::setup()
{
    addRoute("POST", "/login", LoginController, login);
    addRoute("GET", "/login/status", LoginController, status);
}
Exemple #17
0
void Song::readRoute(Xml& xml)/*{{{*/
{
	QString src;
	QString dst;
	int ch = -1;
	int chs = -1;
	int remch = -1;

	Route sroute, droute;

	for (;;)
	{
		const QString& tag = xml.s1();
		Xml::Token token = xml.parse();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				if (tag == "source")
				{
					sroute.read(xml);
					sroute.channel = ch;
					sroute.channels = chs;
					sroute.remoteChannel = remch;
				}
				else if (tag == "dest")
				{
					droute.read(xml);
					droute.channel = ch;
					droute.channels = chs;
					droute.remoteChannel = remch;
				}
				else
					xml.unknown("readRoute");
				break;
			case Xml::Attribut:
#ifdef ROUTE_DEBUG
				printf("Song::readRoute(): attribute:%s\n", tag.toLatin1().constData());
#endif
				if (tag == "channel")
					ch = xml.s2().toInt();
				else
					if (tag == "channels")
					chs = xml.s2().toInt();
				else
					if (tag == "remch")
					remch = xml.s2().toInt();
				else
					if (tag == "channelMask") // p3.3.50 New channel mask for midi port-track routes.
					ch = xml.s2().toInt();
				else
					printf("Song::readRoute(): unknown attribute:%s\n", tag.toLatin1().constData());
				break;
			case Xml::TagEnd:
				if (xml.s1() == "Route")
				{
					if (sroute.isValid() && droute.isValid())// Support new routes.
					{
						// p3.3.49 Support pre- 1.1-RC2 midi-device-to-track routes. Obsolete. Replaced with midi port routes.
						if (sroute.type == Route::MIDI_DEVICE_ROUTE && droute.type == Route::TRACK_ROUTE)
						{
							if (sroute.device->midiPort() >= 0 && sroute.device->midiPort() < MIDI_PORTS
									&& ch >= 0 && ch < MIDI_CHANNELS)
							{
								sroute.midiPort = sroute.device->midiPort();
								sroute.device = 0;
								sroute.type = Route::MIDI_PORT_ROUTE;

								sroute.channel = 1 << ch; // p3.3.50  Convert to new bit-wise channel mask.
								droute.channel = sroute.channel;

								addRoute(sroute, droute);
							}
							else
								printf("  Warning - device:%s to track route, no device midi port or chan:%d out of range. Ignoring route!\n",
									sroute.device->name().toLatin1().constData(), ch);
						}
						else if (sroute.type == Route::TRACK_ROUTE && droute.type == Route::MIDI_DEVICE_ROUTE)
						{
							if (droute.device->midiPort() >= 0 && droute.device->midiPort() < MIDI_PORTS
									&& ch >= 0 && ch < MIDI_CHANNELS) // p3.3.50
							{
								droute.midiPort = droute.device->midiPort();
								droute.device = 0;
								droute.type = Route::MIDI_PORT_ROUTE;

								droute.channel = 1 << ch; // p3.3.50  Convert to new bit-wise channel mask.
								sroute.channel = droute.channel;

								addRoute(sroute, droute);
							}
							else
								printf("  Warning - track to device:%s route, no device midi port or chan:%d out of range. Ignoring route!\n",
									droute.device->name().toLatin1().constData(), ch);
						}
						else
						{
							//printf("adding new route...\n");
							addRoute(sroute, droute);
						}
					}
					else
						printf("  Warning - route invalid. Ignoring route! srcValid: %d, destValid: %d\n", 
								sroute.isValid(), droute.isValid());

					return;
				}
			default:
				break;
		}
	}
}/*}}}*/
Exemple #18
0
/**
 * The default configurations for the Saffire Pro 24 router.
 *  For coherence with hardware, destinations must follow a specific ordering
 *  There must be 44 destinations at low samplerate
 *  Front LEDs are connected to the first four router entries
 */
void
SaffirePro24::SaffirePro24EAP::setupDefaultRouterConfig_low() {
    unsigned int i;
    // the 1394 stream receivers except the two "loops" one
    //  Looks like analogic inputs are curiously ordered
    //  (required for coherent front LEDs)
    for (i=0; i<2; i++) {
        addRoute(eRS_InS0, i+2, eRD_ATX0, i);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_InS0, i, eRD_ATX0, i+2);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_AES, i+6, eRD_ATX0, i+4);
    }
    for (i=0; i<8; i++) {
        addRoute(eRS_ADAT, i, eRD_ATX0, i+6);
    }
    // The audio ports
    // Ensure that audio port are not muted
    for (i=0; i<6; i++) {
        addRoute(eRS_ARX0, i%2, eRD_InS0, i);
    }
    // the SPDIF receiver
    for (i=0; i<2; i++) {
        addRoute(eRS_Muted, 0, eRD_AES, i+6);
    }
    // the "loops" 1394 stream receivers
    for (i=0; i<2; i++) {
        addRoute(eRS_Muted, 0, eRD_ATX0, i+14);
    }
    // the Mixer inputs
    for (i=0; i<4; i++) {
        addRoute(eRS_InS0, i, eRD_Mixer0, i);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_AES, i+6, eRD_Mixer0, i+4);
    }
    for (i=0; i<8; i++) {
        addRoute(eRS_ADAT, i, eRD_Mixer0, i+6);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_ARX0, i, eRD_Mixer0, i+14);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_Muted, 0, eRD_Mixer1, i);
    }
    // The two mute destinations
    for (i=0; i<2; i++) {
        addRoute(eRS_Mixer, i, eRD_Muted, 0);
    }
}
Exemple #19
0
void MapBox::addRoute(const QGeoCoordinate & start, const QGeoCoordinate & end)
{
    QList<QGeoCoordinate> waypoints;
    waypoints << start << end;
    addRoute(waypoints);
}
BasicFileUploadServer::BasicFileUploadServer(const Settings& settings):
    BasicServer(settings), 
    _fileUploadRoute(FileUploadRoute::makeShared(settings))
{
    addRoute(_fileUploadRoute);
}
Exemple #21
0
int
write_rte(int action,
          u_char * var_val,
          u_char var_val_type,
          size_t var_val_len, u_char * statP, oid * name, size_t length)
{
    struct rtent   *rp;
    int             var;
    long            val;
    u_long          dst;
    char            buf[8];
    u_short         flags;
    int             oldty;

    /*
     * object identifier is of form:
     * 1.3.6.1.2.1.4.21.1.X.A.B.C.D ,  where A.B.C.D is IP address.
     * IPADDR starts at offset 10.
     */

    if (length != 14) {
        snmp_log(LOG_ERR, "length error\n");
        return SNMP_ERR_NOCREATION;
    }

#ifdef solaris2		/* not implemented */
    return SNMP_ERR_NOTWRITABLE;
#endif

    var = name[9];

    dst = *((u_long *) & name[10]);

    rp = findCacheRTE(dst);

    if (!rp) {
        rp = cacheKernelRTE(dst);
    }


    if (action == RESERVE1 && !rp) {

        rp = newCacheRTE();
        if (!rp) {
            snmp_log(LOG_ERR, "newCacheRTE");
            return SNMP_ERR_RESOURCEUNAVAILABLE;
        }
        rp->rt_dst = dst;
        rp->rt_type = rp->xx_type = 2;

    } else if (action == COMMIT) {


    } else if (action == FREE) {
        if (rp && rp->rt_type == 2) { /* was invalid before */
            delCacheRTE(dst);
        }
    }

    netsnmp_assert(NULL != rp); /* should have found or created rp */


    switch (var) {

    case IPROUTEDEST:

        if (action == RESERVE1) {

            if (var_val_type != ASN_IPADDRESS) {
                snmp_log(LOG_ERR, "not IP address");
                return SNMP_ERR_WRONGTYPE;
            }

            memcpy(buf, var_val, (var_val_len > 8) ? 8 : var_val_len);

            rp->xx_dst = *((u_long *) buf);


        } else if (action == COMMIT) {
            rp->rt_dst = rp->xx_dst;
        }
        break;

    case IPROUTEMETRIC1:

        if (action == RESERVE1) {
            if (var_val_type != ASN_INTEGER) {
                snmp_log(LOG_ERR, "not int1");
                return SNMP_ERR_WRONGTYPE;
            }

            val = *((long *) var_val);

            if (val < -1) {
                snmp_log(LOG_ERR, "not right1");
                return SNMP_ERR_WRONGVALUE;
            }

            rp->xx_metric1 = val;

        } else if (action == RESERVE2) {

            if ((rp->xx_metric1 == 1) && (rp->xx_type != 4)) {
                snmp_log(LOG_ERR, "reserve2 failed\n");
                return SNMP_ERR_WRONGVALUE;
            }

        } else if (action == COMMIT) {
            rp->rt_metric1 = rp->xx_metric1;
        }
        break;

    case IPROUTEIFINDEX:

        if (action == RESERVE1) {
            if (var_val_type != ASN_INTEGER) {
                snmp_log(LOG_ERR, "not right2");
                return SNMP_ERR_WRONGTYPE;
            }

            val = *((long *) var_val);

            if (val <= 0) {
                snmp_log(LOG_ERR, "not right3");
                return SNMP_ERR_WRONGVALUE;
            }

            rp->xx_ifix = val;

        } else if (action == COMMIT) {
            rp->rt_ifix = rp->xx_ifix;
        }
        break;

    case IPROUTENEXTHOP:

        if (action == RESERVE1) {

            if (var_val_type != ASN_IPADDRESS) {
                snmp_log(LOG_ERR, "not right4");
                return SNMP_ERR_WRONGTYPE;
            }

            memcpy(buf, var_val, (var_val_len > 8) ? 8 : var_val_len);

            rp->xx_nextIR = *((u_long *) buf);

        } else if (action == COMMIT) {
            rp->rt_nextIR = rp->xx_nextIR;
        }
	break;


    case IPROUTETYPE:

        /*
         *  flag meaning:
         *
         *  IPROUTEPROTO (rt_proto): none: (cant set == 3 (netmgmt)) 
         *
         *  IPROUTEMETRIC1:  1 iff gateway, 0 otherwise
         *  IPROUTETYPE:     4 iff gateway, 3 otherwise
         */

        if (action == RESERVE1) {
            if (var_val_type != ASN_INTEGER) {
                return SNMP_ERR_WRONGTYPE;
            }

            val = *((long *) var_val);

            if ((val < 2) || (val > 4)) {       /* only accept invalid, direct, indirect */
                snmp_log(LOG_ERR, "not right6");
                return SNMP_ERR_WRONGVALUE;
            }

            rp->xx_type = val;

        } else if (action == COMMIT) {

            oldty = rp->rt_type;
            rp->rt_type = rp->xx_type;

            if (rp->rt_type == 2) {     /* invalid, so delete from kernel */

                if (delRoute
                    (rp->rt_dst, rp->rt_nextIR, rp->rt_ifix,
                     rp->old_flags) < 0) {
                    snmp_log_perror("delRoute");
                }

            } else {

                /*
                 * it must be valid now, so flush to kernel 
                 */

                if (oldty != 2) {       /* was the old entry valid ?  */
                    if (delRoute
                        (rp->old_dst, rp->old_nextIR, rp->old_ifix,
                         rp->old_flags) < 0) {
                        snmp_log_perror("delRoute");
                    }
                }

                /*
                 * not invalid, so remove from cache 
                 */

                flags = (rp->rt_type == 4 ? RTF_GATEWAY : 0);

                if (addRoute(rp->rt_dst, rp->rt_nextIR, rp->rt_ifix, flags)
                    < 0) {
                    snmp_log_perror("addRoute");
                }

                delCacheRTE(rp->rt_type);
            }
        }
        break;


    case IPROUTEPROTO:

    default:
        DEBUGMSGTL(("snmpd", "unknown sub-id %d in write_rte\n", var));
        return SNMP_ERR_NOCREATION;


    }

    return SNMP_ERR_NOERROR;
}
Exemple #22
0
QgsGPSData::RouteIterator QgsGPSData::addRoute( const QString& name )
{
  QgsRoute rte;
  rte.name = name;
  return addRoute( rte );
}
BasicIPVideoServer::BasicIPVideoServer(const Settings& settings):
    BasicServer(settings),
    _ipVideoRoute(IPVideoRoute::makeShared(settings))
{
    addRoute(_ipVideoRoute);
}
Exemple #24
0
BasicServer::BasicServer(const Settings& settings):
    BaseServer_<BasicServerSettings>(settings),
    _fileSystemRoute(FileSystemRoute::makeShared(settings))
{
    addRoute(_fileSystemRoute);
}
Exemple #25
0
void Profire2626::Profire2626EAP::setupDefaultRouterConfig_mid()
{
    unsigned int i;

    // ======== the 1394 stream receivers

    // LINE IN
    for (i=0; i<8; i++) {
        addRoute(eRS_InS1, i, eRD_ATX0, i);
    }

    // ADAT A
    for (i=0; i<4; i++) {
        addRoute(eRS_ADAT, i, eRD_ATX0, i+8);
    }

    // ADAT B
    for (i=0; i<4; i++) {
        addRoute(eRS_ADAT, i+4, eRD_ATX1, i);
    }

    // SPDIF
    for (i=0; i<2; i++) {
        addRoute(eRS_AES, i, eRD_ATX1, i+8);
    }


    // ======== Mixer inputs 

    // LINE IN
    for (i=0; i<8; i++) {
        addRoute(eRS_InS1, i, eRD_Mixer0, i);
    }

    // ADAT
    for (i=0; i<8; i++) {
        addRoute(eRS_ADAT, i, eRD_Mixer0, i+8);
    }

    // SPDIF
    for (i=0; i<2; i++) {
        addRoute(eRS_AES, i, eRD_Mixer1, i);
    }

    // ======== Outputs

    // LINE OUT
    for (i=0; i<8; i++) {
        addRoute(eRS_ARX0, i, eRD_InS1, i+2);
    }

    // ADAT A
    for (i=0; i<8; i++) {
        addRoute(eRS_ARX0, i+8, eRD_ADAT, i);
    }

    // ADAT B
    for (i=0; i<8; i++) {
        addRoute(eRS_ARX1, i, eRD_ADAT, i+8);
    }

    // SPDIF
    for (i=0; i<2; i++) {
        addRoute(eRS_ARX1, i+8, eRD_AES, i);
    }

    // Mixer is muted
    for (i=0; i<16; i++) {
        addRoute(eRS_Mixer, i, eRD_Muted, 0);
    }
}
Exemple #26
0
/**
 * The default configuration for the Firestudio Project.
 * 82 destinations; each "group" every 32 registers
 **FIXME What follows is extracted from a listing of an existing router configuration.
 *       However, the origin of such a router configuration was unknown.
 */
void
FirestudioProject::FirestudioProjectEAP::setupDefaultRouterConfig_low() {
    unsigned int i;
    // the 1394 stream receivers
    for (i=0; i<8; i++) {
        addRoute(eRS_InS0, i, eRD_ATX0, i);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_AES, i+2, eRD_ATX0, i+8);
    }
    // Then 22 muted destinations
    for (i=0; i<22; i++) {
        addRoute(eRS_Muted, 0, eRD_Muted, 0);
    }
    
    // the Mixer inputs
    for (i=0; i<8; i++) {
        addRoute(eRS_InS0, i, eRD_Mixer0, i);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_AES, i+2, eRD_Mixer0, i+8);
    }
    for (i=0; i<6; i++) {
        addRoute(eRS_ARX0, i, eRD_Mixer0, i+10);
    }
    for (i=0; i<2; i++) {
        addRoute(eRS_ARX0, i+6, eRD_Mixer1, i);
    }
    // Then 14 muted destinations
    for (i=0; i<14; i++) {
        addRoute(eRS_Muted, 0, eRD_Muted, 0);
    }

    // The audio ports
    // Ensure that audio port are not muted
    for (i=0; i<8; i++) {
        addRoute(eRS_ARX0, i, eRD_InS0, i);
    }
    // The SPDIF ports
    for (i=0; i<2; i++) {
        addRoute(eRS_ARX0, i+8, eRD_AES, i+2);
    }
    // Then 8 muted destinations
    for (i=0; i<8; i++) {
        addRoute(eRS_Muted, 0, eRD_Muted, 0);
    }  
}
int CMakeSip::makeReq(int id, PHONE_CFG * cfg, ADDR *addrExt,STR_64 *str64ExtADDR)
{
   unsigned int iMeth=0;
   unsigned int uiFromLoc=0;
   unsigned int uiFromLen=0;
   strDstAddr.s=(unsigned char *)&spSes->dstSipAddr.strVal;
   strDstAddr.len=(int)spSes->dstSipAddr.uiLen;
   
   
   if(cfg){
      
      if(strcmp(&cfg->szSipTransport[0],"TLS")==0){iIsTCP=0;iIsTLS=1;}
      else if(strcmp(&cfg->szSipTransport[0],"TCP")==0){iIsTCP=1;iIsTLS=0;}
      else if(strcmp(&cfg->szSipTransport[0],"UDP")==0){iIsTCP=0;iIsTLS=0;}
      else {iIsTCP=0;iIsTLS=0;}
      
   }
   
   char *s=buf;
   
   int iPrevId=spSes->cs.iSendS;
   spSes->cs.iSendS=id;
   if(id!=METHOD_ACK)
   {
      if(iPrevId!=spSes->cs.iSendS)
      {
         if(spSes->cs.iSendS==METHOD_OPTIONS){
            spSes->sSendTo.setRetransmit(2,5*T_GT_SECOND);
         }
         else if(iIsTCP || iIsTLS)
            spSes->sSendTo.setRetransmit(7,5*T_GT_SECOND);
         else if(spSes->cs.iSendS==METHOD_REGISTER)
            spSes->sSendTo.setRetransmit(7,1*T_GT_SECOND);
         else  if(spSes->cs.iSendS==METHOD_INVITE)
            spSes->sSendTo.setRetransmit(7,(cfg==NULL || cfg->iNetworkIsMobile)?(6*T_GT_SECOND):(3*T_GT_SECOND));
         else
            spSes->sSendTo.setRetransmit();
      }
      spSes->cs.iWaitS=200;
   }
   else
   {
      spSes->cs.iWaitS=0;
   }
   
   //TODO getITFromZZ
   unsigned int uiCSeq;
#if 1
   if(cfg && id==METHOD_REGISTER)
   {
      if(!cfg->uiSipCSeq){
         //next reg should be with greater CSeq, even app restarts, if call-id is same
         //problem was with SIP Thor on OpenSIPS XS 1.4.5, but not  with FreeSwitch
         
         int get_time();
         cfg->uiSipCSeq=(unsigned int)get_time();
         cfg->uiSipCSeq-=1000000000;
      }
      cfg->uiSipCSeq++;
      uiCSeq=(unsigned int)cfg->uiSipCSeq;
   }
   else if(spSes){
      if(id!=METHOD_ACK && id!=METHOD_CANCEL)spSes->uiSipCseq++;
      uiCSeq=spSes->uiSipCseq;
   }
   else {
      uiCSeq=getTickCount();
      while(uiCSeq>1000000000)uiCSeq-=1000000000;
   }
#else
   static unsigned int  ss=User::TickCount();
   ss++;
   uiCSeq=ss;
   
#endif
   if(!uiCSeq)uiCSeq=1;

   int iReplaceRoute=0;
   
   if(iContactId >(int)sMsg->hldContact.uiCount)
      iContactId=0;

   GET_METH(id,iMeth);
   
   //TODO do we need to send route with cancel msg
#define METHOD_CANCEL_IGNORE 0
   
   struct HOLDER_CONTACT *hc = &sMsg->hldContact;
   HLD_ROUTE *hrr = &sMsg->hldRecRoute;
   
   //do i need to check "&& spSes->sSIPMsg.hldRecRoute.uiCount"?
   if(hc->uiCount<1 && spSes && spSes->sSIPMsg.hldContact.uiCount && sMsg->sipHdr.dstrStatusCode.uiVal>=300){
      hc = &spSes->sSIPMsg.hldContact;
      hrr = &spSes->sSIPMsg.hldRecRoute;
   }
   
   
   if(hc->x[iContactId].sipUri.dstrSipAddr.uiLen && (id & (METHOD_CANCEL_IGNORE|METHOD_REGISTER))==0)
   {
      if(hrr->uiCount)//TODO caller calle
      {
         iReplaceRoute=!hasRouteLR(hrr,0);
      }
      if(iReplaceRoute)
      {
         strDstAddr.s=(unsigned char *)hrr->x[0].sipUri.dstrSipAddr.strVal;
         strDstAddr.len=(int)hrr->x[0].sipUri.dstrSipAddr.uiLen;
      }
      else
      {
         strDstAddr.s=(unsigned char *)hc->x[iContactId].sipUri.dstrSipAddr.strVal;
         strDstAddr.len=(int)hc->x[iContactId].sipUri.dstrSipAddr.uiLen;
      }
   }
   //HDR
   ADD_DSTR(s,uiLen,sip_meth[iMeth]); ADD_CHAR(s,uiLen,' ');
   ADD_L_STR(s,uiLen,strDstAddr.s, strDstAddr.len);ADD_0_STR(s,uiLen," SIP/2.0\r\n");
   
   switch(id)
   {
      case METHOD_INVITE:
         sMsg->hdrCSeq.dstrID.uiVal=uiCSeq;
         break;
      case METHOD_ACK:
      case METHOD_CANCEL:
         uiCSeq=sMsg->hdrCSeq.dstrID.uiVal;
         break;
         
      case METHOD_REFER:
         //  ADD_STR(s,uiLen,"Refer-To: <");
         //ADD_DSTR(s,uiLen,spSes->str32Forward);
         //ADD_0_STR(s,uiLen,">\r\n");
         break;
         
      case METHOD_REGISTER:
         if(sMsg->hdrCSeq.dstrID.uiVal)uiCSeq=sMsg->hdrCSeq.dstrID.uiVal+1;//ast
         sMsg->hdrCSeq.dstrID.uiVal=uiCSeq;
      case METHOD_OPTIONS:
         
         ADD_STR(s,uiLen,"Allow: INVITE,ACK,CANCEL,OPTIONS,MESSAGE,BYE,INFO\r\n");
         if(id==METHOD_OPTIONS)
         {
            ADD_STR(s,uiLen,"Accept: application/sdp, text/plain\r\n");
         }
         break;
         
   }
   //TODO test asterisk add
   if((id & METHOD_REGISTER) && cfg && !cfg->reg.bUnReg && cfg->iUseOnlyNatIp==0 && sMsg &&  sMsg->hldVia.x[0].dstrRecived.uiLen<32)
   {
      if(sMsg->hldVia.x[0].dstrRecived.strVal && sMsg->hldVia.x[0].dstrRecived.uiLen){
         //TODO hi addr
         
         if(str64ExtADDR)
            spSes->pIPVisble=str64ExtADDR;
         
         memcpy(spSes->pIPVisble->strVal
                ,sMsg->hldVia.x[0].dstrRecived.strVal
                ,sMsg->hldVia.x[0].dstrRecived.uiLen);
         
         spSes->pIPVisble->uiLen=sMsg->hldVia.x[0].dstrRecived.uiLen;
         
         if(sMsg->hldVia.x[0].dstrRPort.uiVal)
            spSes->uiUserVisibleSipPort=sMsg->hldVia.x[0].dstrRPort.uiVal;
         
         if(addrExt)
         {
            addrExt->ip=ipstr2long(sMsg->hldVia.x[0].dstrRecived.uiLen,sMsg->hldVia.x[0].dstrRecived.strVal);
            
            SWAP_INT(addrExt->ip);
            addrExt->setPort((unsigned int)spSes->uiUserVisibleSipPort);
            
            
         }
      }
      else if(sMsg->hldVia.x[0].dstrRPort.uiVal){
         //  printf("[reg rport=%d ]",sMsg->hldVia.x[0].dstrRPort.uiVal);
         spSes->uiUserVisibleSipPort=sMsg->hldVia.x[0].dstrRPort.uiVal;
         addrExt->setPort((unsigned int)spSes->uiUserVisibleSipPort);
      }
   }
   
   if(iIsTCP)ADD_STR(s,uiLen,"Via: SIP/2.0/TCP ")
      else if(iIsTLS)ADD_STR(s,uiLen,"Via: SIP/2.0/TLS ")
         else ADD_STR(s,uiLen,"Via: SIP/2.0/UDP ")
            ADD_DSTR(s,uiLen,(*spSes->pIPVisble));
   
   if(spSes->uiUserVisibleSipPort!=DEAFULT_SIP_PORT)
      uiLen += sprintf(s + uiLen, ":%u", spSes->uiUserVisibleSipPort);
   
   ADD_STR(s,uiLen,";rport");
   ADD_STR(s,uiLen,";branch=z9hG4bK");
   ADD_L_STR(s,uiLen,sMsg->dstrCallID.strVal,4);
   if(id!=METHOD_CANCEL)
   {
      ADD_L_STR(s,uiLen,s,2);
   }
   else
   {
      ADD_STR(s,uiLen,"IN");
   }
   
   uiLen += sprintf(s + uiLen, "%u",uiCSeq^0x123);
   
   
   
   
   ADD_CRLF(s,uiLen);
   
   uiLen += sprintf(s + uiLen, "CSeq: %u ", uiCSeq);
   ADD_DSTRCRLF(s,uiLen,sip_meth[iMeth])
   
   
   
   if((id & (METHOD_REGISTER|METHOD_CANCEL))
      || (spSes->cs.iCaller  && (sMsg==NULL || sMsg->hdrCSeq.uiMethodID==0)))
   {
      
      ADD_FSTR(s,uiLen,"From: ",6);
      {
         uiFromLoc=uiLen;
         if(cfg->user.nick[0]){
            ADD_CHAR(s,uiLen,'"');
            ADD_0_STR(s,uiLen,cfg->user.nick);
            ADD_CHAR(s,uiLen,'"');
         }
         uiLen+=sprintf(s+uiLen," <%.*s>",D_STR(spSes->userSipAddr));
         
         uiFromLen=uiLen-uiFromLoc;
         
         if(spSes->str16Tag.uiLen)
         {
            ADD_0_STR(s,uiLen,";tag=");
            ADD_DSTRCRLF(s,uiLen,spSes->str16Tag);
         }
         else ADD_CRLF(s,uiLen);
         
      }
      {
         
         if((sMsg->hdrTo.dstrTag.uiLen==0 && id!=METHOD_REGISTER)
            || (id & METHOD_CANCEL)
            )
         {
            //  puts("a4");
            ADD_FSTR(s,uiLen,"To: <",5);
            //vajag lai straadaatu 3xx vispaar sho laikam jau nevajag,
            //jo es jau iedoshu liidzi sMsg kuru saneemu
            if(spSes && spSes->sSIPMsg.hdrTo.sipUri.dstrSipAddr.uiLen==0)
            {
               spSes->sSIPMsg.hdrTo.sipUri.dstrSipAddr.strVal=
               (char *)&spSes->sSIPMsg.rawDataBuffer+spSes->sSIPMsg.uiOffset;
               ADD_DSTR((char *)&spSes->sSIPMsg.rawDataBuffer, spSes->sSIPMsg.uiOffset,spSes->dstSipAddr);
               
               spSes->sSIPMsg.hdrTo.sipUri.dstrSipAddr.uiLen=spSes->dstSipAddr.uiLen;
               //varbuut sho saglabaat pie get new ses
            }
            if(sMsg->hdrTo.sipUri.dstrSipAddr.strVal)
            {
               ADD_DSTR(s,uiLen,sMsg->hdrTo.sipUri.dstrSipAddr);
            }
            else
            {
               ADD_DSTR(s,uiLen,spSes->dstSipAddr);
            }
            ADD_FSTR(s,uiLen,">\r\n",3);
            
            // puts("a5");
         }
         else if (id==METHOD_REGISTER)
         {
            //  DEBUG(0,"make register---------")
            ADD_FSTR(s,uiLen,"To: ",4);
            memcpy(s+uiLen,s+uiFromLoc,uiFromLen);
            uiLen+=uiFromLen;
            ADD_CRLF(s,uiLen);
         }
         else
         {
            ADD_DSTRCRLF(s,uiLen,sMsg->hdrTo.dstrFullRow);
            //  puts("a6");
         }
      }
   }
   else
   {
      //TODO use full row
      //      char *pMeth1;
      //    char *pMeth2;
      DSTR *fromAddr;
      DSTR *toAddr;
      DSTR *tag;
      //   puts("a7");
      
      if(sMsg->sipHdr.dstrStatusCode.uiVal)
      {
         fromAddr=&sMsg->hdrFrom.sipUri.dstrSipAddr;
         toAddr=&sMsg->hdrTo.sipUri.dstrSipAddr;
         tag=&sMsg->hdrTo.dstrTag;
         //    puts("a8");
      }
      else
      {
         toAddr=&sMsg->hdrFrom.sipUri.dstrSipAddr;
         fromAddr=&sMsg->hdrTo.sipUri.dstrSipAddr;
         tag=&sMsg->hdrFrom.dstrTag;
         //  puts("a9");
      }
      
      uiLen+=sprintf(s+uiLen,"From: <%.*s>", D_STR(*fromAddr));
      if(spSes->str16Tag.uiLen)
      {
         ADD_0_STR(s,uiLen,";tag=");
         ADD_DSTRCRLF(s,uiLen,spSes->str16Tag);
      }
      else ADD_CRLF(s,uiLen);
      

      uiLen+=sprintf(s+uiLen,"To: <%.*s>", D_STR(*toAddr));
      
      if(tag->uiLen && !fToTagIgnore)
      {
         ADD_0_STR(s,uiLen,";tag=");
         ADD_DSTRCRLF(s,uiLen,(*tag));
      }
      else ADD_CRLF(s,uiLen);
   }
   
   ADD_FSTR(s,uiLen,"Call-ID: ",9);
   ADD_DSTRCRLF(s,uiLen,sMsg->dstrCallID);
   ADD_STR(s,uiLen,"Max-Forwards: 70\r\n");
   
   if(id==METHOD_REGISTER){
      if(cfg && cfg->szUA[0]){
         ADD_STR(s,uiLen,"User-Agent: ");
         ADD_0_STR(s,uiLen,cfg->szUA);ADD_CRLF(s,uiLen);
      }
      else{
         ADD_STR(s,uiLen,USER_AGENT);
      }
   }
   
   
   if(id != METHOD_CANCEL_IGNORE && (hrr->uiCount || iReplaceRoute))//(toMake & (METHOD_BYE |METHOD_ACK)) && ???
   {
      
      uiLen+=addRoute(s+uiLen, 255, hrr, "Route: ",
                      !((sMsg->hdrCSeq.uiMethodID && sMsg->sipHdr.dstrStatusCode.uiVal) ||
                        (spSes->cs.iCaller && sMsg->hdrCSeq.uiMethodID==0))
                      ,iReplaceRoute, &hc->x[iContactId].sipUri.dstrSipAddr);
      
   }
   
   if(id & (METHOD_INVITE | METHOD_OPTIONS |METHOD_MESSAGE |METHOD_REGISTER|METHOD_REFER|METHOD_SUBSCRIBE|METHOD_PUBLISH|METHOD_UPDATE))
   {
      //unsigned int uiPos;
      if(cfg && cfg->user.nick[0]){
         uiLen+=sprintf(s+uiLen,"Contact: \"%s\" <sip:",cfg->user.nick);//sUserCfg.szUserName);
      }
      else {ADD_STR(s,uiLen,"Contact: <sip:");}
      //uiPos=uiLen;
      
      //TODO if register store contact addr and use it until next reg
      
      if(cfg  && (cfg->isOnline() || (id & METHOD_REGISTER)))
      {
         if(*cfg->user.nr)
            uiLen+=sprintf(s+uiLen,"%s@",cfg->user.nr);
         else if(*cfg->user.un)
            uiLen+=sprintf(s+uiLen,"%s@",cfg->user.un);
      }
      
      ADD_DSTR(s,uiLen,(*spSes->pIPVisble));
      
      
      if(spSes->uiUserVisibleSipPort!=DEAFULT_SIP_PORT)
         uiLen+=sprintf(s+uiLen,":%u",spSes->uiUserVisibleSipPort);
      
      
      
      if(iIsTCP) {ADD_STR(s,uiLen,";transport=tcp>")}else
         if(iIsTLS) {ADD_STR(s,uiLen,";transport=tls>")} else
         { ADD_FSTR(s,uiLen,">",1)}
Exemple #28
0
void RouteNode::addRoute(TokenSet tokens,int matchId){
    addRoute(tokens.begin(),tokens.end(),matchId);
}
Exemple #29
0
//-------------------------------------------------------------------------------------
void GhostManager::pushRouteMessage(ENTITY_ID entityID, COMPONENT_ID componentID, Mercury::Bundle* pBundle)
{
	pushMessage(componentID, pBundle);
	addRoute(entityID, componentID);
}
Exemple #30
0
BasicPostServer::BasicPostServer(const Settings& settings):
    BasicServer(settings),
    _postRoute(PostRoute::makeShared(settings))
{
    addRoute(_postRoute);
}