how to get the sip info from the sofia-sip in the unimrcp - unimrcp

I used unimrcp1.7.0, and i need to know the detail of SIP info.
I tried in the callback function mrcp_sofia_eventcallback in the file mrcp_sofiasip_server_agent.c.
the callback funtion is defined as:
static void mrcp_sofia_event_callback(
nua_event_t nua_event,
int status,
char const *phrase,
nua_t *nua,
mrcp_sofia_agent_t *sofia_agent,
nua_handle_t *nh,
mrcp_sofia_session_t *sofia_session,
sip_t const *sip,
tagi_t tags[])
i can get sip info when the sofia-sip get INVITE from client, and call the callback, but when sofia-sip response to the client, it made the sip pointer NULL, so I can not get the SIP info.

Related

Twilio Studio/Functions and Conference calls

I'm using the Studio flow to manage authenticating an end user calling into our number, and assuming they pass authentication, they then get added to a conference call - however so that I can set the various parameters for starting the conference call, I'm trying to initiate the join conference function in a Functions called from Studio.
So example:
End user if confirmed, and the next step in the Studio flow calls a Function called "Start Call". A variable passed to the start call function includes the Conference Name.
exports.handler = function(context, event, callback) {
console.log('Function - /startCall');
const conference_id = event.conference_id;
let twiml = new Twilio.twiml.VoiceResponse();
twiml.say('Please wait while we dial you into the call.');
twiml.dial().conference(conference_id);
console.log('TWIML',twiml);
return callback(null, twiml);
};
This then returns back to the Studio Flow, so as a test, my next part is to dial a 3rd party into the same conference call - so another request from the flow to a function called conferenceOperator:
exports.handler = function (context, event, callback) {
console.log('Function - /conferenceOperator');
const conference_id = event.conference_id;
console.log('CONFERENCE',conference_id );
const twilioClient = context.getTwilioClient();
console.log(twilioClient.studio);
twilioClient.studio.flows('FWxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').executions.create({
to: '+44xxxxxxxxxxxx',
from: '+44xxxxxxxxxx',
parameters: JSON.stringify({
call_id: conference_id
})
})
.then(function(execution) {
console.log(execution.sid);
callback(null, execution.sid);
})
.catch(error => {
console.error(`problem with request: ${error.message}`);
callback(error.message);
});
The number is dialed, and is put on hold waiting for the conference to start. However the moment this flow starts, the original inbound call is dropped. Looking at the logs for the Studio flow, it shows as still executing.
So questions:
why does the inbound call drop?
am I handling transferring the inbound call across to the conference via the function correctly?
what gotchas have I missed?
Thanks
I have now resolved this - there was an odd error in another part of the flow, which was returning an http-error 500 - this caused the whole flow to fail, and thus end the call without reporting back!

How to stop replyTo so that #SendTo works

I have Java code similar to this in a class called "MyService" to receive messages, process the object passed and return a response, with the intention to have the returned response using the configured exchange and routing key, as specified using the #SendTo annotation:
#RabbitListener(containerFactory = "myContainerFactory", queues = RabbitConfig.MY_QUEUE_NAME)
#SendTo("#{T(com.acme.config.RabbitOutboundConfig).OUTBOUND_EXCHANGE_NAME + '/' + myService.getRoutingKey()}")
public OrderResponse handlePaidOrder(Order order) {
// do processing on the input Order object here...
OrderResponse orderResponse = new OrderResponse();
// fill up response object here
return orderResponse;
}
public String getRoutingKey() {
String routingKey;
// .. custom logic to build a routing key
return routingKey;
}
This makes sense and works fine. The problem I am having is I can't figure out how to stop the "reply_to" property from coming in the message. I know if my sender configures a RabbitTemplate by calling setReplyAddress, that will result in a reply_to property and a correlation_id in the message.
However, if I simply do not call setReplyAddress, I still get a reply_to property, one that looks like this:
reply_to: amq.rabbitmq.reply-to.g2dkAAxyYWJiaXRAd3NK and so forth
and with that reply_to in the message, #SendTo has no effect. The Spring AMQP docs and this post: Dynamic SendTo annotation state:
The #SendTo is only used if there's no replyTo in the message.
Furthermore, when I don't call setReplyAddress on the RabbitTemplate, I don't get a correlation-id either. I pretty sure I am going to need that. So, my question is, how do I get my sender to generate a correlation-id but to not generate a reply-to so that my receiver can use the #SendTo annotation?
Thanks much in advance.
The correlationId is for the sender; it's not needed with direct reply-to since the channel is reserved; you could add a MessagePostProcessor on the sending side to add a correlationId.
The #SendTo is a fallback in case there is no reply_to header.
If you want to change that behavior you can add an afterReceivePostProcessor to the listener container to remove the replyTo property on the MessageProperties.
container.setAfterReceivePostProcessor(m -> {
m.getMessageProperties().setReplyTo(null);
return m;
}
Bear in mind, though, that if the sender set a replyTo, he is likely expecting a reply, so sending the reply someplace else is going to disappoint him and likely will cause some delay there until the reply times out.
If you mean you want to send an initial reply someplace else that does some more work and then finally replies to the originator, then you should save off the replyTo in another header, and reinstate it (or use an expression that references the saved-off header).

Get message type from PipeContext from MassTransit

I am implementing a MassTransit middleware in my receive end point to record the performance of handling the message, i want to get the message type from the PipeContext, how can i get it?
public async Task Send(T context, IPipe<T> next)
{
// I want to know the message type from here so that i can log it
using (_logger.BeginTimedOperation("Time for handling message", null, LogEventLevel.Debug))
{
await next.Send(context);
}
}
You would need to intercept at the ConsumeContext, which has a property for the message types from the serialization envelope.
Then, you can get the supported message types using:
IEnumerable<string> SupportedMessageTypes {get;}
That should get you what you need to log the message type with the duration.
So a filter along the lines of:
public class LogMessageTypeFilter :
IFilter<ConsumeContext>
{
}
Implement the send method, call next within the method, and then take action after the next pipe completes.

stack in AtlAdvise trying to create a connection between OPC server and the client (callback object)

Create Instance of Callback Object using an ATL template
CComObject<COPCDataCallback>::CreateInstance(&pCOPCDataCallback);
pCbUnk = pCOPCDataCallback->GetUnknown();
it stacked at
HRESULT hRes = AtlAdvise(m_IOPCGroupStateMgt, // [in] IUnknown Interface of the Connection Point
pCbUnk, // [in] IUnknown Interface of the Callback object
IID_IOPCDataCallback,// [in] Connection Point ID: The OPC Data Callback
m_dwAdvise // [out] Cookie that that uniquely identifies the connection
);
unhandled exception at XXXX ntdll.dll
before that I added ATL support to the MFC project
https://stackoverflow.com/a/8046824/4270170
any ideas to solve this issue?
thanks.
It seems to be my fault that the type of the fourth param of AtlAdvise is DWORD,but there is something wrong with this param I set.And now everything goes well.Thank you all.

Openssl tls srp

Id like to use srp in my current project. But im kinda at a loss as to how i would implement that with openssl. I got the client side running but i dont know how to write the server side. I also couldnt find any documentation orexample implementations of use. What i want is to store the login information inside a database and then retrieve that data when needed. Im using poco for most of the network part so writing the client was rather easy and i sucessfully tested it against other servers. So i would be gratefull for hints as to how to implement the server side.
There is an example of how to do this in file ssl/ssltest.c in OpenSSL archive.
At a high level you register an authentication callback. This callback is called automatically as necessary during SSL_Accept() to authenticate your users.
From ssltest.c example callback looks like the following:
static int MS_CALLBACK ssl_srp_server_param_cb(SSL *s, int *ad, void *arg)
{
SRP_SERVER_ARG * p = (SRP_SERVER_ARG *) arg;
if (strcmp(p->expected_user, SSL_get_srp_username(s)) != 0)
{
fprintf(stderr, "User %s doesn't exist\n", SSL_get_srp_username(s));
return SSL3_AL_FATAL;
}
if (SSL_set_srp_server_param_pw(s,p->expected_user,p->pass,NULL)<0)
{
*ad = SSL_AD_INTERNAL_ERROR;
return SSL3_AL_FATAL;
}
return SSL_ERROR_NONE;
}
To register you call
SSL_CTX_set_srp_username_callback(s_ctx, ssl_srp_server_param_cb);
The arg parameter of callback function is a void pointer passed to your callback so that you can reference any necessary application context in your application from the callback.
To set arg parameter call SSL_CTX_set_srp_cb_arg(s_ctx, mypointer);
It is really this easy. Be sure SRP ciphers are being included in your cipher list.
There is a way to get feedback on autentication failures that can be used to implement countermeasure against high rate online dictionary attack.
To do this call SSL_CTX_set_info_callback(s_ctx,mynotifycallback) to register your callback. Had success using condition below to filter unrelated notifications.
void mynotifycallback(const SSL *s, int reason, int ret)
{
if (reason & SSL_CB_ALERT && ret & SSL3_AD_BAD_RECORD_MAC && SSL_get_srp_username((SSL *)s))
// authentication failure
}