Writing directly to an IAX2 peer

Is there a way to write raw data to an IAX2 peer? i.e. not a voice packet or IAX2 frame or anything associated with a call. Basically I just want to send data from one asterisk over the trunk to the other asterisk. i.e. a networked Hello World program. I tried calling send with the sockfd value in the IAX2 peer structure and just some dummy data as a test, but it returns a -1.

Out of the box, no, there is no way to do that.

You could extend the protocol to send whatever you’d like. You’d define a new IAX2 frame type (see iax2.h for the existing frame types), then add the necessary handling to send/receive the frame. I’m not sure what you’d do with the data once you got it, but presumably you have some intention surrounding that.

The IAX2 RFC documents the existing frame types, and would give you a grounding in the protocol implemented in chan_iax2.

That is exactly what I am trying to do. I modified iax2.h to add a new ast_control_frame_type, but I can’t figure out the “necessary handling to send/receive the frame”. I tried looking at ast_queue_control_data, but it requires a channel. Basically any write method I found assumes an active call which makes complete sense, but I was hoping underneath the covers there was a method called that I could use.

Asterisk is written in plain C, but in an object oriented style. The functions you see are, essentially methods, but the object is passed as an explicit parameters.

Generally, when you call one of the channel methods, it does some common processing, then calls a method on the individual channel, which does the technology specific processing,

Queuing a frame is all generic. The technology specific part happens in ast_read.

Generally, though, this is the wrong forum for this level of technical detail.

Sorry about that. Where is the technical forum located?

Development discussion is usually done on the asterisk-dev mailing list.

As an aside, if you reach out for some assistance on the -dev list, it might help to understand more of what you’re trying to accomplish. As you pointed out, IAX2 generally assumes you have a channel for most operations (although there are some, such as registration, that doesn’t expect this). The more detail you can provide on your implementation, the better as well.