예제 #1
0
파일: testpart.cpp 프로젝트: chrizzoy/yate
void SS7Testing::setParams(const NamedList& params, bool setSeq)
{
    if (!m_timer.interval() || params.getParam(YSTRING("interval")))
	m_timer.interval(params,"interval",20,1000,true);
    m_len = params.getIntValue(YSTRING("length"),m_len);
    m_sharing = params.getBoolValue(YSTRING("sharing"),m_sharing);
    if (m_len > 1024)
	m_len = 1024;
    if (setSeq || !m_seq)
	m_seq = params.getIntValue(YSTRING("sequence"),m_seq);
    const String* lbl = params.getParam(YSTRING("address"));
    if (!TelEngine::null(lbl)) {
	// TYPE,opc,dpc,sls,spare
	SS7PointCode::Type t = SS7PointCode::Other;
	ObjList* l = lbl->split(',');
	const GenObject* o = l->at(0);
	if (o) {
	    t = SS7PointCode::lookup(o->toString());
	    if (t == SS7PointCode::Other)
		t = m_lbl.type();
	}
	if (t != SS7PointCode::Other) {
	    o = l->at(1);
	    if (o) {
		SS7PointCode c(m_lbl.opc());
		if (c.assign(o->toString(),t))
		    m_lbl.assign(t,m_lbl.dpc(),c,m_lbl.sls(),m_lbl.spare());
	    }
	    o = l->at(2);
	    if (o) {
		SS7PointCode c(m_lbl.dpc());
		if (c.assign(o->toString(),t))
		    m_lbl.assign(t,c,m_lbl.opc(),m_lbl.sls(),m_lbl.spare());
	    }
	    o = l->at(3);
	    if (o) {
		int sls = o->toString().toInteger(-1);
		if (sls >= 0)
		    m_lbl.setSls(sls);
	    }
	    o = l->at(4);
	    if (o) {
		int spare = o->toString().toInteger(-1);
		if (spare >= 0)
		    m_lbl.setSpare(spare);
	    }
	}
	delete l;
    }
}
예제 #2
0
파일: testpart.cpp 프로젝트: chrizzoy/yate
bool SS7Testing::control(NamedList& params)
{
    String* ret = params.getParam(YSTRING("completion"));
    const String* oper = params.getParam(YSTRING("operation"));
    const char* cmp = params.getValue(YSTRING("component"));
    int cmd = oper ? oper->toInteger(s_dict_control,-1) : -1;

    if (ret) {
	if (oper && (cmd < 0))
	    return false;
	String part = params.getValue(YSTRING("partword"));
	if (cmp) {
	    if (toString() != cmp)
		return false;
	    for (const TokenDict* d = s_dict_control; d->token; d++)
		Module::itemComplete(*ret,d->token,part);
	    return true;
	}
	return Module::itemComplete(*ret,toString(),part);
    }

    if (!(cmp && toString() == cmp))
	return false;
    if (cmd >= 0) {
	Lock mylock(this);
	setParams(params,true);
	switch (cmd) {
	    case CMD_STOP:
		m_timer.stop();
		return true;
	    case CMD_START:
		if (!(m_timer.interval() && m_lbl.length()))
		    return false;
		m_timer.start();
		return sendTraffic();
	    case CMD_SINGLE:
		if (!m_lbl.length())
		    return false;
		m_timer.stop();
		return sendTraffic();
	    case CMD_RESET:
		m_timer.stop();
		m_lbl.assign(SS7PointCode::Other,m_lbl.opc(),m_lbl.dpc(),m_lbl.sls());
		return true;
	}
    }
    return SignallingComponent::control(params);
}
예제 #3
0
파일: media.cpp 프로젝트: CimpianAlin/yate
// Append all paramters from one named list to another, inserting keys prefix
static void putNamedList(NamedList& dst, const NamedList& src, String prefix)
{
    unsigned int n = src.length();
    for (unsigned int i = 0; i < n; i++) {
	const NamedString* param = src.getParam(i);
	if (param)
	    dst.addParam(prefix + param->name(),*param);
    }
}
예제 #4
0
파일: session.cpp 프로젝트: wdaniels/yate
SDPSession::SDPSession(SDPParser* parser, NamedList& params)
    : m_parser(parser), m_mediaStatus(MediaMissing),
      m_rtpForward(false), m_sdpForward(false), m_rtpMedia(0),
      m_sdpSession(0), m_sdpVersion(0)
{
    m_rtpForward = params.getBoolValue("rtp_forward");
    m_secure = params.getBoolValue("secure",parser->m_secure);
    m_rfc2833 = parser->m_rfc2833;
    setRfc2833(params.getParam("rfc2833"));
}
예제 #5
0
bool CallInfo::copyParam(const NamedList& original, const String& name, bool clear)
{
    NamedString* param = original.getParam(name);
    if (param) {
        setParam(name,param->c_str());
        return true;
    }
    else if (clear)
        clearParam(name);
    return false;
}
예제 #6
0
파일: uart.cpp 프로젝트: bastienhappe/yate
// Append a parameter to a buffer
// Truncate it or set error if fail is true and parameter length exceeds maxLen
// Return: 0 if the parameter is missing
//         -1 if the parameter is too long
//         1 on success
int appendParam(ObjList& msg, NamedList& params, unsigned char value,
	unsigned char maxLen, bool fail)
{
    NamedString* ns = params.getParam(lookup(value,ETSIModem::s_msgParams));
    if (!ns)
	return 0;
    unsigned char len = ns->length();
    if (len > maxLen) {
	if (fail) {
	    params.setParam("error",ns->name() + "-too-long");
	    return -1;
	}
	len = maxLen;
    }
    DataBlock* data = new DataBlock;
    unsigned char a[2] = {value,len};
    FSKModem::addRaw(*data,a,sizeof(a));
    FSKModem::addRaw(*data,(void*)ns->c_str(),len);
    msg.append(data);
    return 1;
}
예제 #7
0
파일: session.cpp 프로젝트: wdaniels/yate
// Update from parameters. Build a default SDP if no media is found in params
bool SDPSession::updateSDP(const NamedList& params)
{
    DDebug(m_parser,DebugAll,"SDPSession::updateSdp('%s') [%p]",params.c_str(),this);
    bool defaults = true;
    const char* sdpPrefix = params.getValue("osdp-prefix","osdp");
    ObjList* lst = 0;
    unsigned int n = params.length();
    String defFormats;
    m_parser->getAudioFormats(defFormats);
    for (unsigned int i = 0; i < n; i++) {
	const NamedString* p = params.getParam(i);
	if (!p)
	    continue;
	// search for rtp_port or rtp_port_MEDIANAME parameters
	String tmp(p->name());
	if (!tmp.startSkip("media",false))
	    continue;
	if (tmp && (tmp[0] != '_'))
	    continue;
	// since we found at least one media declaration disable defaults
	defaults = false;
	// now tmp holds the suffix for the media, null for audio
	bool audio = tmp.null();
	// check if media is supported, default only for audio
	if (!p->toBoolean(audio))
	    continue;
	String fmts = params.getValue("formats" + tmp);
	if (audio && fmts.null())
	    fmts = defFormats;
	if (fmts.null())
	    continue;
	String trans = params.getValue("transport" + tmp,"RTP/AVP");
	String crypto;
	if (m_secure)
	    crypto = params.getValue("crypto" + tmp);
	if (audio)
	    tmp = "audio";
	else
	    tmp >> "_";
	SDPMedia* rtp = 0;
	// try to take the media descriptor from the old list
	if (m_rtpMedia) {
	    ObjList* om = m_rtpMedia->find(tmp);
	    if (om)
		rtp = static_cast<SDPMedia*>(om->remove(false));
	}
	bool append = false;
	if (rtp)
	    rtp->update(fmts);
	else {
	    rtp = new SDPMedia(tmp,trans,fmts);
	    append = true;
	}
	rtp->crypto(crypto,false);
	if (sdpPrefix) {
	    for (unsigned int j = 0; j < n; j++) {
		const NamedString* param = params.getParam(j);
		if (!param)
		    continue;
		tmp = param->name();
		if (tmp.startSkip(sdpPrefix + rtp->suffix() + "_",false) && (tmp.find('_') < 0))
		    rtp->parameter(tmp,*param,append);
	    }
	}
	if (!lst)
	    lst = new ObjList;
	lst->append(rtp);
    }
    if (defaults && !lst) {
	lst = new ObjList;
	lst->append(new SDPMedia("audio","RTP/AVP",params.getValue("formats",defFormats)));
    }
    return setMedia(lst);
}