[svn-commits] branch north/chan_skinny-fixup r34576 -
/team/north/chan_skinny-fixup/channels/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Sun Jun 18 02:38:22 MST 2006
Author: north
Date: Sun Jun 18 04:38:22 2006
New Revision: 34576
URL: http://svn.digium.com/view/asterisk?rev=34576&view=rev
Log:
convert all protocol struct ints to uint32_t (more to come)
fix up some of the IP handling stuff...
need to do something about ast_ouraddrfor being SIP specific...
the way it is right now, in some cases, __ourip will be 127.0.0.1
this obviously won't work for rtp streams
is skinny at all like iax2, where the ip is passed in the message?
likely so...we just need to figure out where it is
Modified:
team/north/chan_skinny-fixup/channels/chan_skinny.c
Modified: team/north/chan_skinny-fixup/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/north/chan_skinny-fixup/channels/chan_skinny.c?rev=34576&r1=34575&r2=34576&view=diff
==============================================================================
--- team/north/chan_skinny-fixup/channels/chan_skinny.c (original)
+++ team/north/chan_skinny-fixup/channels/chan_skinny.c Sun Jun 18 04:38:22 2006
@@ -134,64 +134,64 @@
#define REGISTER_MESSAGE 0x0001
typedef struct register_message {
char name[16];
- int userId;
- int instance;
- char ip[4];
- int type;
- int maxStreams;
+ uint32_t userId;
+ uint32_t instance;
+ uint32_t ip;
+ uint32_t type;
+ uint32_t maxStreams;
} register_message;
#define IP_PORT_MESSAGE 0x0002
#define KEYPAD_BUTTON_MESSAGE 0x0003
typedef struct keypad_button_message {
- int button;
- int lineInstance;
- int callReference;
+ uint32_t button;
+ uint32_t lineInstance;
+ uint32_t callReference;
} keypad_button_message;
#define STIMULUS_MESSAGE 0x0005
typedef struct stimulus_message {
- int stimulus;
- int stimulusInstance;
- int unknown1;
+ uint32_t stimulus;
+ uint32_t stimulusInstance;
+ uint32_t unknown1;
} stimulus_message;
#define OFFHOOK_MESSAGE 0x0006
typedef struct offhook_message {
- int unknown1;
- int unknown2;
+ uint32_t unknown1;
+ uint32_t unknown2;
} offhook_message;
#define ONHOOK_MESSAGE 0x0007
typedef struct onhook_message {
- int unknown1;
- int unknown2;
+ uint32_t unknown1;
+ uint32_t unknown2;
} onhook_message;
#define CAPABILITIES_RES_MESSAGE 0x0010
typedef struct station_capabilities {
- int codec;
- int frames;
+ uint32_t codec;
+ uint32_t frames;
union {
char res[8];
- long rate;
+ uint64_t rate;
} payloads;
} station_capabilities;
typedef struct capabilities_res_message {
- int count;
+ uint32_t count;
struct station_capabilities caps[18];
} capabilities_res_message;
#define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A
typedef struct speed_dial_stat_req_message {
- int speedDialNumber;
+ uint32_t speedDialNumber;
} speed_dial_stat_req_message;
#define LINE_STATE_REQ_MESSAGE 0x000B
typedef struct line_state_req_message {
- int lineNumber;
+ uint32_t lineNumber;
} line_state_req_message;
#define TIME_DATE_REQ_MESSAGE 0x000D
@@ -209,19 +209,19 @@
#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
typedef struct open_receive_channel_ack_message {
- int status;
- char ipAddr[4];
- int port;
- int passThruId;
+ uint32_t status;
+ uint32_t ipAddr;
+ uint32_t port;
+ uint32_t passThruId;
} open_receive_channel_ack_message;
#define SOFT_KEY_SET_REQ_MESSAGE 0x0025
#define SOFT_KEY_EVENT_MESSAGE 0x0026
typedef struct soft_key_event_message {
- int softKeyEvent;
- int instance;
- int reference;
+ uint32_t softKeyEvent;
+ uint32_t instance;
+ uint32_t reference;
} soft_key_event_message;
#define UNREGISTER_MESSAGE 0x0027
@@ -231,67 +231,67 @@
#define REGISTER_ACK_MESSAGE 0x0081
typedef struct register_ack_message {
- int keepAlive;
+ uint32_t keepAlive;
char dateTemplate[6];
char res[2];
- int secondaryKeepAlive;
+ uint32_t secondaryKeepAlive;
char res2[4];
} register_ack_message;
#define START_TONE_MESSAGE 0x0082
typedef struct start_tone_message {
- int tone;
+ uint32_t tone;
} start_tone_message;
#define STOP_TONE_MESSAGE 0x0083
#define SET_RINGER_MESSAGE 0x0085
typedef struct set_ringer_message {
- int ringerMode;
- int unknown1; /* See notes in transmit_ringer_mode */
- int unknown2;
+ uint32_t ringerMode;
+ uint32_t unknown1; /* See notes in transmit_ringer_mode */
+ uint32_t unknown2;
} set_ringer_message;
#define SET_LAMP_MESSAGE 0x0086
typedef struct set_lamp_message {
- int stimulus;
- int stimulusInstance;
- int deviceStimulus;
+ uint32_t stimulus;
+ uint32_t stimulusInstance;
+ uint32_t deviceStimulus;
} set_lamp_message;
#define SET_SPEAKER_MESSAGE 0x0088
typedef struct set_speaker_message {
- int mode;
+ uint32_t mode;
} set_speaker_message;
/* XXX When do we need to use this? */
#define SET_MICROPHONE_MESSAGE 0x0089
typedef struct set_microphone_message {
- int mode;
+ uint32_t mode;
} set_microphone_message;
#define START_MEDIA_TRANSMISSION_MESSAGE 0x008A
typedef struct media_qualifier {
- int precedence;
- int vad;
- int packets;
- int bitRate;
+ uint32_t precedence;
+ uint32_t vad;
+ uint32_t packets;
+ uint32_t bitRate;
} media_qualifier;
typedef struct start_media_transmission_message {
- int conferenceId;
- int passThruPartyId;
- char remoteIp[4];
- int remotePort;
- int packetSize;
- int payloadType;
+ uint32_t conferenceId;
+ uint32_t passThruPartyId;
+ uint32_t remoteIp;
+ uint32_t remotePort;
+ uint32_t packetSize;
+ uint32_t payloadType;
media_qualifier qualifier;
} start_media_transmission_message;
#define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
typedef struct stop_media_transmission_message {
- int conferenceId;
- int passThruPartyId;
+ uint32_t conferenceId;
+ uint32_t passThruPartyId;
} stop_media_transmission_message;
#define CALL_INFO_MESSAGE 0x008F
@@ -300,39 +300,39 @@
char callingParty[24];
char calledPartyName[40];
char calledParty[24];
- int instance;
- int reference;
- int type;
+ uint32_t instance;
+ uint32_t reference;
+ uint32_t type;
char originalCalledPartyName[40];
char originalCalledParty[24];
} call_info_message;
#define SPEED_DIAL_STAT_RES_MESSAGE 0x0091
typedef struct speed_dial_stat_res_message {
- int speedDialNumber;
+ uint32_t speedDialNumber;
char speedDialDirNumber[24];
char speedDialDisplayName[40];
} speed_dial_stat_res_message;
#define LINE_STAT_RES_MESSAGE 0x0092
typedef struct line_stat_res_message {
- int lineNumber;
+ uint32_t lineNumber;
char lineDirNumber[24];
char lineDisplayName[42];
- int space;
+ uint32_t space;
} line_stat_res_message;
#define DEFINETIMEDATE_MESSAGE 0x0094
typedef struct definetimedate_message {
- int year; /* since 1900 */
- int month;
- int dayofweek; /* monday = 1 */
- int day;
- int hour;
- int minute;
- int seconds;
- int milliseconds;
- int timestamp;
+ uint32_t year; /* since 1900 */
+ uint32_t month;
+ uint32_t dayofweek; /* monday = 1 */
+ uint32_t day;
+ uint32_t hour;
+ uint32_t minute;
+ uint32_t seconds;
+ uint32_t milliseconds;
+ uint32_t timestamp;
} definetimedate_message;
#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
@@ -418,8 +418,8 @@
typedef struct server_res_message {
server_identifier server[5];
- int serverListenPort[5];
- int serverIpAddr[5];
+ uint32_t serverListenPort[5];
+ uint32_t serverIpAddr[5];
} server_res_message;
#define RESET_MESSAGE 0x009F
@@ -431,25 +431,25 @@
#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
typedef struct open_receive_channel_message {
- int conferenceId;
- int partyId;
- int packets;
- int capability;
- int echo;
- int bitrate;
+ uint32_t conferenceId;
+ uint32_t partyId;
+ uint32_t packets;
+ uint32_t capability;
+ uint32_t echo;
+ uint32_t bitrate;
} open_receive_channel_message;
#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
typedef struct close_receive_channel_message {
- int conferenceId;
- int partyId;
+ uint32_t conferenceId;
+ uint32_t partyId;
} close_receive_channel_message;
#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
typedef struct soft_key_template_definition {
char softKeyLabel[16];
- int softKeyEvent;
+ uint32_t softKeyEvent;
} soft_key_template_definition;
#define KEYDEF_ONHOOK 0
@@ -598,9 +598,9 @@
};
typedef struct soft_key_template_res_message {
- int softKeyOffset;
- int softKeyCount;
- int totalSoftKeyCount;
+ uint32_t softKeyOffset;
+ uint32_t softKeyCount;
+ uint32_t totalSoftKeyCount;
soft_key_template_definition softKeyTemplateDefinition[32];
} soft_key_template_res_message;
@@ -621,43 +621,43 @@
#define SELECT_SOFT_KEYS_MESSAGE 0x0110
typedef struct select_soft_keys_message {
- int instance;
- int reference;
- int softKeySetIndex;
- int validKeyMask;
+ uint32_t instance;
+ uint32_t reference;
+ uint32_t softKeySetIndex;
+ uint32_t validKeyMask;
} select_soft_keys_message;
#define CALL_STATE_MESSAGE 0x0111
typedef struct call_state_message {
- int callState;
- int lineInstance;
- int callReference;
+ uint32_t callState;
+ uint32_t lineInstance;
+ uint32_t callReference;
} call_state_message;
#define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112
typedef struct display_prompt_status_message {
- int messageTimeout;
+ uint32_t messageTimeout;
char promptMessage[32];
- int lineInstance;
- int callReference;
+ uint32_t lineInstance;
+ uint32_t callReference;
} display_prompt_status_message;
#define DISPLAY_NOTIFY_MESSAGE 0x0114
typedef struct display_notify_message {
- int displayTimeout;
+ uint32_t displayTimeout;
char displayMessage[100];
} display_notify_message;
#define ACTIVATE_CALL_PLANE_MESSAGE 0x0116
typedef struct activate_call_plane_message {
- int lineInstance;
+ uint32_t lineInstance;
} activate_call_plane_message;
#define DIALED_NUMBER_MESSAGE 0x011D
typedef struct dialed_number_message {
char dialedNumber[24];
- int lineInstance;
- int callReference;
+ uint32_t lineInstance;
+ uint32_t callReference;
} dialed_number_message;
typedef union {
@@ -690,6 +690,7 @@
offhook_message offhook;
onhook_message onhook;
set_speaker_message setspeaker;
+ set_microphone_message setmicrophone;
call_info_message callinfo;
start_media_transmission_message startmedia;
stop_media_transmission_message stopmedia;
@@ -725,7 +726,8 @@
static char ourhost[256];
static int ourport;
static struct in_addr __ourip;
-struct ast_hostent ahp; struct hostent *hp;
+struct ast_hostent ahp;
+struct hostent *hp;
static int skinnysock = -1;
static pthread_t tcp_thread;
static pthread_t accept_t;
@@ -783,6 +785,9 @@
#define SKINNY_SPEAKERON 1
#define SKINNY_SPEAKEROFF 2
+
+#define SKINNY_MICON 1
+#define SKINNY_MICOFF 2
#define SKINNY_OFFHOOK 1
#define SKINNY_ONHOOK 2
@@ -1227,8 +1232,6 @@
struct skinny_line *l;
struct skinny_subchannel *sub = NULL;
- ast_log(LOG_WARNING, "find_subchannel_by_reference: %d\n", reference);
-
for (l = d->lines; l; l = l->next) {
for (sub = l->sub; sub; sub = sub->next) {
if (sub->callid == reference)
@@ -1302,7 +1305,18 @@
req->data.setspeaker.mode = htolel(mode);
transmit_response(s, req);
}
-
+/*
+static void transmit_microphone_mode(struct skinnysession *s, int mode)
+{
+ skinny_req *req;
+
+ if (!(req = req_alloc(sizeof(struct set_microphone_message), SET_MICROPHONE_MESSAGE)))
+ return;
+
+ req->data.setmicrophone.mode = htolel(mode);
+ transmit_response(s, req);
+}
+*/
static void transmit_callstate(struct skinnysession *s, int instance, int state, unsigned callid)
{
skinny_req *req;
@@ -1799,6 +1813,8 @@
d->lastlineinstance = 1;
while(v) {
if (!strcasecmp(v->name, "host")) {
+ /* In Dec '04, this option was made useless, since ast_getaddrfor now only supports SIP */
+ /* XXX We should probably document this fact or remove this functionality. */
if (ast_get_ip(&d->addr, v->value)) {
free(d);
return NULL;
@@ -1946,11 +1962,12 @@
d->addr.sin_port = htons(DEFAULT_SKINNY_PORT);
}
if (d->addr.sin_addr.s_addr) {
+ /* XXX See note above, in 'host' option. */
if (ast_ouraddrfor(&d->addr.sin_addr, &d->ourip)) {
- memcpy(&d->ourip, &__ourip, sizeof(d->ourip));
+ d->ourip = __ourip;
}
} else {
- memcpy(&d->ourip, &__ourip, sizeof(d->ourip));
+ d->ourip = __ourip;
}
}
return d;
@@ -2227,7 +2244,7 @@
if (ast->_state != AST_STATE_UP) {
ast_setstate(ast, AST_STATE_UP);
}
- transmit_tone(s, SKINNY_NOTONE);
+ transmit_tone(s, SKINNY_SILENCE);
transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
transmit_displaypromptstatus(s, "Connected", 0, l->instance, sub->callid);
return res;
@@ -3199,13 +3216,14 @@
static int handle_server_request_message(skinny_req *req, struct skinnysession *s)
{
+ struct skinny_device *d = s->device;
if (!(req = req_alloc(sizeof(server_res_message), SERVER_RES_MESSAGE)))
return -1;
memcpy(req->data.serverres.server[0].serverName, ourhost,
sizeof(req->data.serverres.server[0].serverName));
req->data.serverres.serverListenPort[0] = htolel(ourport);
- req->data.serverres.serverIpAddr[0] = htolel(__ourip.s_addr);
+ req->data.serverres.serverIpAddr[0] = htolel(d->ourip.s_addr);
transmit_response(s, req);
return 1;
}
@@ -3227,7 +3245,7 @@
struct sockaddr_in sin;
struct sockaddr_in us;
char iabuf[INET_ADDRSTRLEN];
- char addr[4];
+ uint32_t addr;
int port;
int status;
int passthruid;
@@ -3237,17 +3255,13 @@
ast_log(LOG_ERROR, "Open Receive Channel Failure\n");
return 0;
}
- /* ENDIAN */
- memcpy(addr, req->data.openreceivechannelack.ipAddr, sizeof(addr));
- port = htolel(req->data.openreceivechannelack.port);
- passthruid = htolel(req->data.openreceivechannelack.passThruId);
+ addr = letohl(req->data.openreceivechannelack.ipAddr);
+ port = letohl(req->data.openreceivechannelack.port);
+ passthruid = letohl(req->data.openreceivechannelack.passThruId);
sin.sin_family = AF_INET;
- /* I smell endian problems */
- memcpy(&sin.sin_addr, addr, sizeof(sin.sin_addr));
+ sin.sin_addr.s_addr = addr;
sin.sin_port = htons(port);
- if (skinnydebug)
- ast_verbose("ipaddr = %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
sub = find_subchannel_by_reference(d, passthruid);
@@ -3263,12 +3277,18 @@
ast_log(LOG_ERROR, "No RTP structure, this is very bad\n");
return 0;
}
+
+ if (skinnydebug) {
+ ast_verbose("ipaddr = %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_verbose("ourip = %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), d->ourip), ntohs(us.sin_port));
+ }
+
if (!(req = req_alloc(sizeof(start_media_transmission_message), START_MEDIA_TRANSMISSION_MESSAGE)))
return -1;
req->data.startmedia.conferenceId = 0;
req->data.startmedia.passThruPartyId = htolel(sub->callid);
- memcpy(req->data.startmedia.remoteIp, &d->ourip, 4); /* Endian? */
+ req->data.startmedia.remoteIp = htolel(d->ourip.s_addr);
req->data.startmedia.remotePort = htolel(ntohs(us.sin_port));
req->data.startmedia.packetSize = htolel(20);
req->data.startmedia.payloadType = htolel(convert_cap(l->capability));
@@ -4081,8 +4101,9 @@
}
v = v->next;
}
+
if (ntohl(bindaddr.sin_addr.s_addr)) {
- memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
+ __ourip = bindaddr.sin_addr;
} else {
hp = ast_gethostbyname(ourhost, &ahp);
if (!hp) {
More information about the svn-commits
mailing list