[asterisk-commits] russell: branch group/chan_unistim r88282 - /team/group/chan_unistim/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Nov 2 11:44:45 CDT 2007
Author: russell
Date: Fri Nov 2 11:44:44 2007
New Revision: 88282
URL: http://svn.digium.com/view/asterisk?view=rev&rev=88282
Log:
various doxygen updates, and renaming things to match guidelines
Modified:
team/group/chan_unistim/channels/chan_unistim.c
Modified: team/group/chan_unistim/channels/chan_unistim.c
URL: http://svn.digium.com/view/asterisk/team/group/chan_unistim/channels/chan_unistim.c?view=diff&rev=88282&r1=88281&r2=88282
==============================================================================
--- team/group/chan_unistim/channels/chan_unistim.c (original)
+++ team/group/chan_unistim/channels/chan_unistim.c Fri Nov 2 11:44:44 2007
@@ -205,7 +205,8 @@
/* #define DEBUG_TIMER ast_verbose */
#define DEBUG_TIMER dummy
-static int unistimdebug = 0; /*!< Enable verbose output. can also be set with the CLI */
+/*! Enable verbose output. can also be set with the CLI */
+static int unistimdebug = 0;
static int unistim_reload(int fd, int argc, char *argv[]);
static int unistim_port;
static enum autoprovision autoprovisioning = AUTOPROVISIONING_NO;
@@ -214,10 +215,14 @@
static struct io_context *io;
static struct sched_context *sched;
static struct sockaddr_in public_ip = { 0, };
-static struct sockaddr_in addr_from; /*!< give the IP address for the last packet received */
-static unsigned int size_addr_from = sizeof(addr_from); /*!< size of the sockaddr_in (in WSARecvFrom) */
-static unsigned char *buff; /*!< Receive buffer address */
-static unsigned char flag = 0; /*!< Used for test */
+/*! give the IP address for the last packet received */
+static struct sockaddr_in addr_from;
+/*! size of the sockaddr_in (in WSARecvFrom) */
+static unsigned int size_addr_from = sizeof(addr_from);
+/*! Receive buffer address */
+static unsigned char *buff;
+/*! Used for test */
+static unsigned char flag = 0;
static int unistim_reloading = 0;
AST_MUTEX_DEFINE_STATIC(unistim_reload_lock);
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
@@ -366,73 +371,94 @@
char ringstyle;
};
+/*!
+ * \todo Convert to stringfields
+ */
struct unistim_line {
ast_mutex_t lock;
- char name[80]; /* Like 200 */
- char fullname[80]; /* Like USTM/200 at black */
- struct unistim_subchannel *subs[MAX_SUBS]; /* pointer to our current connection, channel... */
- char exten[AST_MAX_EXTENSION]; /* Extention where to start */
- char context[AST_MAX_EXTENSION]; /* Context */
- char language[MAX_LANGUAGE]; /* Language for asterisk sounds */
- char cid_num[AST_MAX_EXTENSION]; /* Caller*ID */
- char mailbox[AST_MAX_EXTENSION]; /* Mailbox to check - used by MWI */
- int lastmsgssent; /* Used by MWI */
- time_t nextmsgcheck; /* Used by MWI */
- char musicclass[MAX_MUSICCLASS]; /* Music On Hold */
- unsigned int callgroup; /* Call Group - untested */
- unsigned int pickupgroup; /* Call Group - untested */
- char accountcode[80]; /* Billing stuff */
- int amaflags; /* Billing stuff */
- int capability; /* Codec supported */
+ /*! Like 200 */
+ char name[80];
+ /*! Like USTM/200 at black */
+ char fullname[80];
+ /*! pointer to our current connection, channel... */
+ struct unistim_subchannel *subs[MAX_SUBS];
+ /*! Extension where to start */
+ char exten[AST_MAX_EXTENSION];
+ /*! Context to start in */
+ char context[AST_MAX_EXTENSION];
+ /*! Language for asterisk sounds */
+ char language[MAX_LANGUAGE];
+ /*! CallerID Number */
+ char cid_num[AST_MAX_EXTENSION];
+ /*! Mailbox for MWI */
+ char mailbox[AST_MAX_EXTENSION];
+ /*! Used by MWI */
+ int lastmsgssent;
+ /*! Used by MWI */
+ time_t nextmsgcheck;
+ /*! MusicOnHold class */
+ char musicclass[MAX_MUSICCLASS];
+ /*! Call group */
+ unsigned int callgroup;
+ /*! Pickup group */
+ unsigned int pickupgroup;
+ /*! Account code (for billing) */
+ char accountcode[80];
+ /*! AMA flags (for billing) */
+ int amaflags;
+ /*! Codec supported */
+ int capability;
struct unistim_line *next;
struct unistim_device *parent;
};
+/*!
+ * \brief A device containing one or more lines
+ */
static struct unistim_device {
- /* A device containing one or more lines */
- int receiver_state; /* state of the receiver (see ReceiverState) */
- int size_phone_number; /* size of the phone number */
- char phone_number[16]; /* the phone number entered by the user */
- char redial_number[16]; /* the last phone number entered by the user */
- int phone_current; /* Number of the current phone */
- int pos_fav; /* Position of the displayed favorites (used for scrolling) */
- char id[18]; /* mac address of the current phone in ascii */
- char name[DEVICE_NAME_LEN]; /* name of the device */
- int softkeylinepos; /* position of the line softkey (default 0) */
- char softkeylabel[6][11]; /* soft key label */
- char softkeynumber[6][16]; /* number dialed when the soft key is pressed */
- char softkeyicon[6]; /* icon number */
- char softkeydevice[6][16]; /* name of the device monitored */
- struct unistim_device *sp[6]; /* pointer to the device monitored by this soft key */
- char maintext0[25]; /* when the phone is idle, display this string on line 0 */
- char maintext1[25]; /* when the phone is idle, display this string on line 1 */
- char maintext2[25]; /* when the phone is idle, display this string on line 2 */
- char titledefault[13]; /* title (text before date/time) */
- char datetimeformat; /* format used for displaying time/date */
- char contrast; /* contrast */
- char country[3]; /* country used for dial tone frequency */
- struct ind_tone_zone *tz; /* Tone zone for res_indications (ring, busy, congestion) */
- char ringvolume; /* Ring volume */
- char ringstyle; /* Ring melody */
- int rtp_port; /* RTP port used by the phone */
- int rtp_method; /* Select the unistim data used to establish a RTP session */
- int status_method; /* Select the unistim packet used for sending status text */
- char codec_number; /* The current codec used to make calls */
- int missed_call; /* Number of call unanswered */
- int callhistory; /* Allowed to record call history */
- char lst_cid[TEXT_LENGTH_MAX]; /* Last callerID received */
- char lst_cnm[TEXT_LENGTH_MAX]; /* Last callername recevied */
- char call_forward[AST_MAX_EXTENSION]; /* Forward number */
- int output; /* Handset, headphone or speaker */
- int previous_output; /* Previous output */
- int volume; /* Default volume */
- int mute; /* Mute mode */
- int moh; /* Music on hold in progress */
- int nat; /* Used by the obscure ast_rtp_setnat */
- enum autoprov_extn extension; /* See ifdef EXTENSION for valid values */
- char extension_number[11]; /* Extension number entered by the user */
- char to_delete; /* Used in reload */
- time_t start_call_timestamp; /* timestamp for the length calculation of the call */
+ int receiver_state; /*!< state of the receiver (see ReceiverState) */
+ int size_phone_number; /*!< size of the phone number */
+ char phone_number[16]; /*!< the phone number entered by the user */
+ char redial_number[16]; /*!< the last phone number entered by the user */
+ int phone_current; /*!< Number of the current phone */
+ int pos_fav; /*!< Position of the displayed favorites (used for scrolling) */
+ char id[18]; /*!< mac address of the current phone in ascii */
+ char name[DEVICE_NAME_LEN]; /*!< name of the device */
+ int softkeylinepos; /*!< position of the line softkey (default 0) */
+ char softkeylabel[6][11]; /*!< soft key label */
+ char softkeynumber[6][16]; /*!< number dialed when the soft key is pressed */
+ char softkeyicon[6]; /*!< icon number */
+ char softkeydevice[6][16]; /*!< name of the device monitored */
+ struct unistim_device *sp[6]; /*!< pointer to the device monitored by this soft key */
+ char maintext0[25]; /*!< when the phone is idle, display this string on line 0 */
+ char maintext1[25]; /*!< when the phone is idle, display this string on line 1 */
+ char maintext2[25]; /*!< when the phone is idle, display this string on line 2 */
+ char titledefault[13]; /*!< title (text before date/time) */
+ char datetimeformat; /*!< format used for displaying time/date */
+ char contrast; /*!< contrast */
+ char country[3]; /*!< country used for dial tone frequency */
+ struct ind_tone_zone *tz; /*!< Tone zone for res_indications (ring, busy, congestion) */
+ char ringvolume; /*!< Ring volume */
+ char ringstyle; /*!< Ring melody */
+ int rtp_port; /*!< RTP port used by the phone */
+ int rtp_method; /*!< Select the unistim data used to establish a RTP session */
+ int status_method; /*!< Select the unistim packet used for sending status text */
+ char codec_number; /*!< The current codec used to make calls */
+ int missed_call; /*!< Number of call unanswered */
+ int callhistory; /*!< Allowed to record call history */
+ char lst_cid[TEXT_LENGTH_MAX]; /*!< Last callerID received */
+ char lst_cnm[TEXT_LENGTH_MAX]; /*!< Last callername recevied */
+ char call_forward[AST_MAX_EXTENSION]; /*!< Forward number */
+ int output; /*!< Handset, headphone or speaker */
+ int previous_output; /*!< Previous output */
+ int volume; /*!< Default volume */
+ int mute; /*!< Mute mode */
+ int moh; /*!< Music on hold in progress */
+ int nat; /*!< Used by the obscure ast_rtp_setnat */
+ enum autoprov_extn extension; /*!< See ifdef EXTENSION for valid values */
+ char extension_number[11]; /*!< Extension number entered by the user */
+ char to_delete; /*!< Used in reload */
+ time_t start_call_timestamp; /*!< timestamp for the length calculation of the call */
struct ast_silence_generator *silence_generator;
struct unistim_line *lines;
struct ast_ha *ha;
@@ -442,55 +468,58 @@
static struct unistimsession {
ast_mutex_t lock;
- struct sockaddr_in sin; /* IP address of the phone */
- struct sockaddr_in sout; /* IP address of server */
- int timeout; /* time-out in ticks : resend packet if no ack was received before the timeout occured */
- unsigned short seq_phone; /* sequence number for the next packet (when we receive a request) */
- unsigned short seq_server; /* sequence number for the next packet (when we send a request) */
- unsigned short last_seq_ack; /* sequence number of the last ACK received */
- unsigned long tick_next_ping; /* time for the next ping */
- int last_buf_available; /* number of a free slot */
- int nb_retransmit; /* number of retransmition */
- int state; /* state of the phone (see phone_state) */
- int size_buff_entry; /* size of the buffer used to enter datas */
- char buff_entry[16]; /* Buffer for temporary datas */
- char macaddr[18]; /* mac adress of the phone (not always available) */
- struct wsabuf wsabufsend[MAX_BUF_NUMBER]; /* Size of each paquet stored in the buffer array & pointer to this buffer */
- unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]; /* Buffer array used to keep the lastest non-acked paquets */
+ struct sockaddr_in sin; /*!< IP address of the phone */
+ struct sockaddr_in sout; /*!< IP address of server */
+ int timeout; /*!< time-out in ticks : resend packet if no ack was received before the timeout occured */
+ unsigned short seq_phone; /*!< sequence number for the next packet (when we receive a request) */
+ unsigned short seq_server; /*!< sequence number for the next packet (when we send a request) */
+ unsigned short last_seq_ack; /*!< sequence number of the last ACK received */
+ unsigned long tick_next_ping; /*!< time for the next ping */
+ int last_buf_available; /*!< number of a free slot */
+ int nb_retransmit; /*!< number of retransmition */
+ int state; /*!< state of the phone (see phone_state) */
+ int size_buff_entry; /*!< size of the buffer used to enter datas */
+ char buff_entry[16]; /*!< Buffer for temporary datas */
+ char macaddr[18]; /*!< mac adress of the phone (not always available) */
+ struct wsabuf wsabufsend[MAX_BUF_NUMBER]; /*!< Size of each paquet stored in the buffer array & pointer to this buffer */
+ unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]; /*!< Buffer array used to keep the lastest non-acked paquets */
struct unistim_device *device;
struct unistimsession *next;
} *sessions = NULL;
-/* Format of datagrams :
-bytes 0 & 1 : ffff for discovery packet, 0000 for everything else
-byte 2 : sequence number (high part)
-byte 3 : sequence number (low part)
-byte 4 : 2 = ask question or send info, 1 = answer or ACK, 0 = retransmit request
-byte 5 : direction, 1 = server to phone, 2 = phone to server
-arguments */
-
-const static unsigned char PacketRcvDiscovery[] =
+/*!
+ * \page Unitstim datagram formats
+ *
+ * Format of datagrams :
+ * bytes 0 & 1 : ffff for discovery packet, 0000 for everything else
+ * byte 2 : sequence number (high part)
+ * byte 3 : sequence number (low part)
+ * byte 4 : 2 = ask question or send info, 1 = answer or ACK, 0 = retransmit request
+ * byte 5 : direction, 1 = server to phone, 2 = phone to server arguments
+ */
+
+const static unsigned char packet_rcv_discovery[] =
{ 0xff, 0xff, 0xff, 0xff, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
-static unsigned char PacketSendDiscoveryACK[] =
+static unsigned char packet_send_discovery_ack[] =
{ 0x00, 0x00, /*Initial Seq (2 bytes) */ 0x00, 0x00, 0x00, 0x01 };
-const static unsigned char PacketRecvFirmVersion[] =
+const static unsigned char packet_recv_firm_version[] =
{ 0x00, 0x00, 0x00, 0x13, 0x9a, 0x0a, 0x02 };
-const static unsigned char PacketRecvPressedKey[] =
+const static unsigned char packet_recv_pressed_key[] =
{ 0x00, 0x00, 0x00, 0x13, 0x99, 0x04, 0x00 };
const static unsigned char PacketRecvPickUp[] =
{ 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x04 };
-const static unsigned char PacketRecvHangUp[] =
+const static unsigned char packet_recv_hangup[] =
{ 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x03 };
-const static unsigned char PacketRecvR2[] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 };
-
-/* TransportAdapter */
-const static unsigned char PacketRecvResumeConnectionWithServer[] =
+const static unsigned char packet_recv_r2[] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 };
+
+/*! TransportAdapter */
+const static unsigned char packet_recv_resume_connection_with_server[] =
{ 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
-const static unsigned char PacketRecvMacAddr[] =
+const static unsigned char packet_recv_mac_addr[] =
{ 0xff, 0xff, 0xff, 0xff, 0x9a, 0x0d, 0x07, 0x31, 0x38 /*MacAddr */ };
-const static unsigned char PacketSendDateTime3[] =
+const static unsigned char packet_send_date_time3[] =
{ 0x11, 0x09, 0x02, 0x02, /*Month */ 0x05, /*Day */ 0x06, /*Hour */ 0x07,
/*Minutes */ 0x08, 0x32
};
@@ -501,7 +530,7 @@
0x05, 0x12, 0x00, 0x78
};
-const static unsigned char PacketSendNoRing[] =
+const static unsigned char Packetsend_no_ring[] =
{ 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00 };
const static unsigned char PacketSendS4[] =
{ 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff,
@@ -538,7 +567,7 @@
0x04, 0x1a, 0x01, 0x16, 0x05, 0x12, 0x13 /* Ring type 10 to 17 */ , 0x18, 0x16, 0x04, 0x18, /* volume 00, 10, 20... */
0x20, 0x16, 0x04, 0x10, 0x00
};
-const static unsigned char PacketSendEndCall[] =
+const static unsigned char Packetsend_end_call[] =
{ 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x31, 0x00, 0x00, 0x19, 0x04, 0x00,
0x10, 0x19, 0x04, 0x00, 0x18, 0x16, 0x05,
0x04, 0x00, 0x00, 0x16, 0x04, 0x37, 0x10
@@ -584,7 +613,7 @@
const static unsigned char PacketSendArrow[] = { 0x17, 0x04, 0x04, 0x00 };
const static unsigned char PacketSendBlinkCursor[] = { 0x17, 0x04, 0x10, 0x86 };
-const static unsigned char PacketSendDateTime2[] = { 0x17, 0x04, 0x17, 0x3d, 0x11, 0x09, 0x02, 0x0a, /*Month */ 0x05, /*Day */
+const static unsigned char Packetsend_date_time2[] = { 0x17, 0x04, 0x17, 0x3d, 0x11, 0x09, 0x02, 0x0a, /*Month */ 0x05, /*Day */
0x06, /*Hour */ 0x07, /*Minutes */ 0x08, 0x32
};
const static unsigned char PacketSendContrast[] =
@@ -608,7 +637,7 @@
const static unsigned char PacketSendTitle[] =
{ 0x17, 0x10, 0x19, 0x02, /*text */ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20 /*end_text */ };
-const static unsigned char PacketSendText[] =
+const static unsigned char Packetsend_text[] =
{ 0x17, 0x1e, 0x1b, 0x04, /*pos */ 0x00, /*inverse */ 0x25, /*text */ 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
@@ -630,7 +659,7 @@
const static unsigned char PacketSendQueryBasicManager10[] = { 0x1a, 0x04, 0x01, 0x10 };
const static unsigned char PacketSendS1[] = { 0x1a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x13 };
-static unsigned char PacketSendPing[] =
+static unsigned char Packetsend_ping[] =
{ 0x1e, 0x05, 0x12, 0x00, /*Watchdog timer */ 0x78 };
#define BUFFSEND unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
@@ -639,33 +668,31 @@
const static char tdesc[] = "UNISTIM Channel Driver";
const static char type[] = "USTM";
-/* Protos */
+/*! Protos */
static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state);
static int load_module(void);
static int reload(void);
static int unload_module(void);
static int reload_config(void);
-static void ShowMainPage(struct unistimsession *pte);
-static struct ast_channel *unistim_request(const char *type, int format, void *data,
- int *cause);
+static void show_main_page(struct unistimsession *pte);
+static struct ast_channel *unistim_request(const char *type, int format,
+ void *data, int *cause);
static int unistim_call(struct ast_channel *ast, char *dest, int timeout);
static int unistim_hangup(struct ast_channel *ast);
static int unistim_answer(struct ast_channel *ast);
static struct ast_frame *unistim_read(struct ast_channel *ast);
static int unistim_write(struct ast_channel *ast, struct ast_frame *frame);
static int unistim_indicate(struct ast_channel *ast, int ind, const void *data,
- size_t datalen);
+ size_t datalen);
static int unistim_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static int unistim_senddigit_begin(struct ast_channel *ast, char digit);
-static int unistim_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
+static int unistim_senddigit_end(struct ast_channel *ast, char digit,
+ unsigned int duration);
static int unistim_sendtext(struct ast_channel *ast, const char *text);
-int WriteEntryHistory(struct unistimsession *pte, FILE * f, char c, char *line1);
-void ChangeCallerID(struct unistimsession *pte, int type, char *callerid);
-int usecount(void);
-char *key(void);
-char *description(void);
-
+static int write_entry_history(struct unistimsession *pte, FILE * f, char c,
+ char *line1);
+static void change_callerid(struct unistimsession *pte, int type, char *callerid);
static const struct ast_channel_tech unistim_tech = {
.type = type,
@@ -686,11 +713,13 @@
/* .bridge = ast_rtp_bridge, */
};
-static void DisplayLastError(const char *szMessage)
+static void display_last_error(const char *szMessage)
{
int dwLastError;
char *lpMsgBuf;
- time_t cur_time = time(0);
+ time_t cur_time;
+
+ time(&cur_time);
dwLastError = errno;
lpMsgBuf = strerror(dwLastError);
@@ -703,12 +732,15 @@
static void GetLocalTime(struct systemtime * systime)
{
struct tm *stm;
- time_t cur_time = time(0);
+ time_t cur_time;
+
+ time(&cur_time);
if ((stm = localtime(&cur_time)) == 0) {
- DisplayLastError("Error in localtime()");
+ display_last_error("Error in localtime()");
return;
}
+
systime->w_year = stm->tm_year;
systime->w_month = stm->tm_mon + 1;
systime->w_day_of_week = stm->tm_wday;
@@ -717,7 +749,6 @@
systime->w_minute = stm->tm_min;
systime->w_second = stm->tm_sec;
systime->w_milliseconds = 0;
- return;
}
static unsigned int GetTickCount(void)
@@ -725,13 +756,14 @@
struct timeval tv;
if (gettimeofday(&tv, NULL) == -1)
- DisplayLastError("Error in gettimeofday");
+ display_last_error("Error in gettimeofday");
+
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
/* Send data to a phone without retransmit nor buffering */
static void
-SendRawClient(int size, unsigned char *data, struct sockaddr_in *addr_to,
+send_raw_client(int size, unsigned char *data, struct sockaddr_in *addr_to,
const struct sockaddr_in *addr_ourip)
{
#ifdef HAVE_PKTINFO
@@ -775,15 +807,15 @@
#endif
if (sendmsg(unistimsock, &msg, 0) == -1)
- DisplayLastError("Error sending datas");
+ display_last_error("Error sending datas");
#else
if (sendto(unistimsock, data, size, 0, (struct sockaddr *) addr_to, sizeof(*addr_to))
== -1)
- DisplayLastError("Error sending datas");
+ display_last_error("Error sending datas");
#endif
}
-static void SendClient(int size, const unsigned char *data, struct unistimsession *pte)
+static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
{
unsigned int tick;
int buf_pos;
@@ -810,20 +842,20 @@
buf_pos);
}
/*#endif */
- SendRawClient(pte->wsabufsend[buf_pos].len, pte->wsabufsend[buf_pos].buf, &(pte->sin),
+ send_raw_client(pte->wsabufsend[buf_pos].len, pte->wsabufsend[buf_pos].buf, &(pte->sin),
&(pte->sout));
pte->last_buf_available++;
ast_mutex_unlock(&pte->lock);
}
-static void SendPing(struct unistimsession *pte)
+static void send_ping(struct unistimsession *pte)
{
BUFFSEND;
if ((unistimdebug) && (option_verbose > 5))
ast_verbose("Sending ping\n");
pte->tick_next_ping = GetTickCount() + unistim_keepalive;
- memcpy(buffsend + SIZE_HEADER, PacketSendPing, sizeof(PacketSendPing));
- SendClient(SIZE_HEADER + sizeof(PacketSendPing), buffsend, pte);
+ memcpy(buffsend + SIZE_HEADER, Packetsend_ping, sizeof(Packetsend_ping));
+ send_client(SIZE_HEADER + sizeof(Packetsend_ping), buffsend, pte);
}
static int getToAddress(int fd, struct sockaddr_in *toAddr)
@@ -859,7 +891,7 @@
/* Allocate memory & initialize structures for a new phone */
/* addr_from : ip address of the phone */
-static struct unistimsession *CreateClient(const struct sockaddr_in *addr_from)
+static struct unistimsession *create_client(const struct sockaddr_in *addr_from)
{
int tmp;
struct unistimsession *s;
@@ -897,13 +929,13 @@
return s;
}
-static void SendEndCall(struct unistimsession *pte)
+static void send_end_call(struct unistimsession *pte)
{
BUFFSEND;
if (unistimdebug)
ast_verbose("Sending end call\n");
- memcpy(buffsend + SIZE_HEADER, PacketSendEndCall, sizeof(PacketSendEndCall));
- SendClient(SIZE_HEADER + sizeof(PacketSendEndCall), buffsend, pte);
+ memcpy(buffsend + SIZE_HEADER, Packetsend_end_call, sizeof(Packetsend_end_call));
+ send_client(SIZE_HEADER + sizeof(Packetsend_end_call), buffsend, pte);
}
static void SetPingTimer(struct unistimsession *pte)
@@ -945,7 +977,7 @@
if (unistimdebug)
ast_verbose("Sending start timer\n");
memcpy(buffsend + SIZE_HEADER, PacketSendStartTimer, sizeof(PacketSendStartTimer));
- SendClient(SIZE_HEADER + sizeof(PacketSendStartTimer), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendStartTimer), buffsend, pte);
}
static void SendStopTimer(struct unistimsession *pte)
@@ -954,7 +986,7 @@
if (unistimdebug)
ast_verbose("Sending stop timer\n");
memcpy(buffsend + SIZE_HEADER, PacketSendStopTimer, sizeof(PacketSendStopTimer));
- SendClient(SIZE_HEADER + sizeof(PacketSendStopTimer), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendStopTimer), buffsend, pte);
}
static void SendIcon(unsigned char pos, unsigned char status, struct unistimsession *pte)
@@ -965,10 +997,10 @@
memcpy(buffsend + SIZE_HEADER, PacketSendIcon, sizeof(PacketSendIcon));
buffsend[9] = pos;
buffsend[10] = status;
- SendClient(SIZE_HEADER + sizeof(PacketSendIcon), buffsend, pte);
-}
-
-static void SendTone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
+ send_client(SIZE_HEADER + sizeof(PacketSendIcon), buffsend, pte);
+}
+
+static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
{
BUFFSEND;
if (!tone1) {
@@ -976,14 +1008,14 @@
ast_verbose("Sending Stream Based Tone Off\n");
memcpy(buffsend + SIZE_HEADER, PacketSendStreamBasedToneOff,
sizeof(PacketSendStreamBasedToneOff));
- SendClient(SIZE_HEADER + sizeof(PacketSendStreamBasedToneOff), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendStreamBasedToneOff), buffsend, pte);
return;
}
/* Since most of the world use a continuous tone, it's useless
if (unistimdebug)
ast_verbose ("Sending Stream Based Tone Cadence Download\n");
memcpy (buffsend + SIZE_HEADER, PacketSendStreamBasedToneCad, sizeof (PacketSendStreamBasedToneCad));
- SendClient (SIZE_HEADER + sizeof (PacketSendStreamBasedToneCad), buffsend, pte); */
+ send_client (SIZE_HEADER + sizeof (PacketSendStreamBasedToneCad), buffsend, pte); */
if (unistimdebug)
ast_verbose("Sending Stream Based Tone Frequency Component List Download %d %d\n",
tone1, tone2);
@@ -993,7 +1025,7 @@
sizeof(PacketSendStreamBasedToneSingleFreq));
buffsend[10] = (tone1 & 0xff00) >> 8;
buffsend[11] = (tone1 & 0x00ff);
- SendClient(SIZE_HEADER + sizeof(PacketSendStreamBasedToneSingleFreq), buffsend,
+ send_client(SIZE_HEADER + sizeof(PacketSendStreamBasedToneSingleFreq), buffsend,
pte);
} else {
tone2 *= 8;
@@ -1003,7 +1035,7 @@
buffsend[11] = (tone1 & 0x00ff);
buffsend[12] = (tone2 & 0xff00) >> 8;
buffsend[13] = (tone2 & 0x00ff);
- SendClient(SIZE_HEADER + sizeof(PacketSendStreamBasedToneDualFreq), buffsend,
+ send_client(SIZE_HEADER + sizeof(PacketSendStreamBasedToneDualFreq), buffsend,
pte);
}
@@ -1011,7 +1043,7 @@
ast_verbose("Sending Stream Based Tone On\n");
memcpy(buffsend + SIZE_HEADER, PacketSendStreamBasedToneOn,
sizeof(PacketSendStreamBasedToneOn));
- SendClient(SIZE_HEADER + sizeof(PacketSendStreamBasedToneOn), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendStreamBasedToneOn), buffsend, pte);
}
/* Positions for favorites
@@ -1039,7 +1071,7 @@
if (i > FAV_MAX_LENGTH)
i = FAV_MAX_LENGTH;
memcpy(buffsend + FAV_MAX_LENGTH + 1, text, i);
- SendClient(SIZE_HEADER + sizeof(PacketSendFavorite), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendFavorite), buffsend, pte);
}
static void RefreshAllFavorite(struct unistimsession *pte)
@@ -1106,7 +1138,7 @@
}
/* Free memory allocated for a phone */
-static void CloseClient(struct unistimsession *s)
+static void close_client(struct unistimsession *s)
{
struct unistim_subchannel *sub;
struct unistimsession *cur, *prev = NULL;
@@ -1123,7 +1155,7 @@
if (cur->device) { /* This session was registred ? */
s->state = STATE_CLEANING;
if (unistimdebug)
- ast_verbose("CloseClient session %p device %p lines %p sub %p\n",
+ ast_verbose("close_client session %p device %p lines %p sub %p\n",
s, s->device, s->device->lines,
s->device->lines->subs[SUB_REAL]);
ChangeFavoriteIcon(s, FAV_ICON_NONE);
@@ -1165,7 +1197,7 @@
if (unistimdebug)
ast_verbose("Too many retransmit - freeing client\n");
ast_mutex_unlock(&pte->lock);
- CloseClient(pte);
+ close_client(pte);
return 1;
}
pte->timeout = GetTickCount() + RETRANSMIT_TIMER;
@@ -1187,7 +1219,7 @@
ast_verbose("Retransmit slot #%d (seq=#0x%.4x), last ack was #0x%.4x\n", i,
seq, pte->last_seq_ack);
}
- SendRawClient(pte->wsabufsend[i].len, pte->wsabufsend[i].buf, &pte->sin,
+ send_raw_client(pte->wsabufsend[i].len, pte->wsabufsend[i].buf, &pte->sin,
&pte->sout);
}
ast_mutex_unlock(&pte->lock);
@@ -1196,24 +1228,24 @@
/* inverse : TEXT_INVERSE : yes, TEXT_NORMAL : no */
static void
-SendText(unsigned char pos, unsigned char inverse, struct unistimsession *pte,
+send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte,
const char *text)
{
int i;
BUFFSEND;
if (unistimdebug)
ast_verbose("Sending text at pos %d, inverse flag %d\n", pos, inverse);
- memcpy(buffsend + SIZE_HEADER, PacketSendText, sizeof(PacketSendText));
+ memcpy(buffsend + SIZE_HEADER, Packetsend_text, sizeof(Packetsend_text));
buffsend[10] = pos;
buffsend[11] = inverse;
i = strlen(text);
if (i > TEXT_LENGTH_MAX)
i = TEXT_LENGTH_MAX;
memcpy(buffsend + 12, text, i);
- SendClient(SIZE_HEADER + sizeof(PacketSendText), buffsend, pte);
-}
-
-static void SendTextStatus(struct unistimsession *pte, const char *text)
+ send_client(SIZE_HEADER + sizeof(Packetsend_text), buffsend, pte);
+}
+
+static void send_textStatus(struct unistimsession *pte, const char *text)
{
BUFFSEND;
int i;
@@ -1231,7 +1263,7 @@
buffsend[9] = pos;
memcpy(buffsend + 10, (j < n) ? (text + j) : " ", 7);
- SendClient(SIZE_HEADER + sizeof(PacketSendStatus2), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendStatus2), buffsend, pte);
}
return;
}
@@ -1243,7 +1275,7 @@
if (i > STATUS_LENGTH_MAX)
i = STATUS_LENGTH_MAX;
memcpy(buffsend + 10, text, i);
- SendClient(SIZE_HEADER + sizeof(PacketSendStatus), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendStatus), buffsend, pte);
}
@@ -1258,7 +1290,7 @@
ast_verbose("Sending LedUpdate (%x)\n", led);
memcpy(buffsend + SIZE_HEADER, PacketSendLedUpdate, sizeof(PacketSendLedUpdate));
buffsend[9] = led;
- SendClient(SIZE_HEADER + sizeof(PacketSendLedUpdate), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendLedUpdate), buffsend, pte);
}
/* output = OUTPUT_HANDSET, OUTPUT_HEADPHONE or OUTPUT_SPEAKER
@@ -1284,7 +1316,7 @@
buffsend[11] = MUTE_ON;
else
buffsend[11] = mute;
- SendClient(SIZE_HEADER + sizeof(PacketSendSelectOutput), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendSelectOutput), buffsend, pte);
if (mute == MUTE_OFF)
SendLedUpdate(pte, 0x18);
else if (mute == MUTE_ON)
@@ -1333,19 +1365,19 @@
memcpy(buffsend + SIZE_HEADER, PacketSendRing, sizeof(PacketSendRing));
buffsend[24] = style + 0x10;
buffsend[29] = volume * 0x10;
- SendClient(SIZE_HEADER + sizeof(PacketSendRing), buffsend, pte);
-}
-
-static void SendNoRing(struct unistimsession *pte)
+ send_client(SIZE_HEADER + sizeof(PacketSendRing), buffsend, pte);
+}
+
+static void send_no_ring(struct unistimsession *pte)
{
BUFFSEND;
if (unistimdebug)
ast_verbose("Sending no ring packet\n");
- memcpy(buffsend + SIZE_HEADER, PacketSendNoRing, sizeof(PacketSendNoRing));
- SendClient(SIZE_HEADER + sizeof(PacketSendNoRing), buffsend, pte);
-}
-
-static void SendTextTitle(struct unistimsession *pte, const char *text)
+ memcpy(buffsend + SIZE_HEADER, Packetsend_no_ring, sizeof(Packetsend_no_ring));
+ send_client(SIZE_HEADER + sizeof(Packetsend_no_ring), buffsend, pte);
+}
+
+static void send_textTitle(struct unistimsession *pte, const char *text)
{
BUFFSEND;
int i;
@@ -1356,7 +1388,7 @@
if (i > 12)
i = 12;
memcpy(buffsend + 10, text, i);
- SendClient(SIZE_HEADER + sizeof(PacketSendTitle), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendTitle), buffsend, pte);
}
@@ -1368,13 +1400,13 @@
ast_verbose("Sending test packet %x\n", flag);
sprintf(text, "first/last char0x%x/0x%x", flag, flag + TEXT_LENGTH_MAX - 1);
- SendText(TEXT_LINE1, TEXT_NORMAL, pte, text);
+ send_text(TEXT_LINE1, TEXT_NORMAL, pte, text);
for (i = 0; i < TEXT_LENGTH_MAX; i++) {
text[i] = flag++;
}
text[i] = '\0';
- SendText(TEXT_LINE0, TEXT_NORMAL, pte, text);
+ send_text(TEXT_LINE0, TEXT_NORMAL, pte, text);
}
static void SendDateTime(struct unistimsession *pte)
{
@@ -1392,10 +1424,10 @@
buffsend[11] = (unsigned char) systime.w_day;
buffsend[12] = (unsigned char) systime.w_hour;
buffsend[13] = (unsigned char) systime.w_minute;
- SendClient(SIZE_HEADER + sizeof(PacketSendDateTime), buffsend, pte);
-}
-
-static void SendDateTime2(struct unistimsession *pte)
+ send_client(SIZE_HEADER + sizeof(PacketSendDateTime), buffsend, pte);
+}
+
+static void send_date_time2(struct unistimsession *pte)
{
BUFFSEND;
struct systemtime systime;
@@ -1405,7 +1437,7 @@
if (unistimdebug)
ast_verbose("Sending Time & Date #2\n");
- memcpy(buffsend + SIZE_HEADER, PacketSendDateTime2, sizeof(PacketSendDateTime2));
+ memcpy(buffsend + SIZE_HEADER, Packetsend_date_time2, sizeof(Packetsend_date_time2));
GetLocalTime(&systime);
if (pte->device)
buffsend[9] = pte->device->datetimeformat;
@@ -1415,10 +1447,10 @@
buffsend[15] = (unsigned char) systime.w_day;
buffsend[16] = (unsigned char) systime.w_hour;
buffsend[17] = (unsigned char) systime.w_minute;
- SendClient(SIZE_HEADER + sizeof(PacketSendDateTime2), buffsend, pte);
-}
-
-static void SendDateTime3(struct unistimsession *pte)
+ send_client(SIZE_HEADER + sizeof(Packetsend_date_time2), buffsend, pte);
+}
+
+static void send_date_time3(struct unistimsession *pte)
{
BUFFSEND;
struct systemtime systime;
@@ -1428,13 +1460,13 @@
if (unistimdebug)
ast_verbose("Sending Time & Date #3\n");
- memcpy(buffsend + SIZE_HEADER, PacketSendDateTime3, sizeof(PacketSendDateTime3));
+ memcpy(buffsend + SIZE_HEADER, packet_send_date_time3, sizeof(packet_send_date_time3));
GetLocalTime(&systime);
buffsend[10] = (unsigned char) systime.w_month;
buffsend[11] = (unsigned char) systime.w_day;
buffsend[12] = (unsigned char) systime.w_hour;
buffsend[13] = (unsigned char) systime.w_minute;
- SendClient(SIZE_HEADER + sizeof(PacketSendDateTime3), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(packet_send_date_time3), buffsend, pte);
}
static void SendBlinkCursor(struct unistimsession *pte)
@@ -1443,7 +1475,7 @@
if (unistimdebug)
ast_verbose("Sending set blink\n");
memcpy(buffsend + SIZE_HEADER, PacketSendBlinkCursor, sizeof(PacketSendBlinkCursor));
- SendClient(SIZE_HEADER + sizeof(PacketSendBlinkCursor), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendBlinkCursor), buffsend, pte);
return;
}
@@ -1456,11 +1488,11 @@
memcpy(buffsend + SIZE_HEADER, PacketSendSetPosCursor,
sizeof(PacketSendSetPosCursor));
buffsend[11] = pos;
- SendClient(SIZE_HEADER + sizeof(PacketSendSetPosCursor), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendSetPosCursor), buffsend, pte);
return;
}
-static void RcvResumeConnectionWithServer(struct unistimsession *pte)
+static void rcv_resume_connection_with_server(struct unistimsession *pte)
{
BUFFSEND;
if (unistimdebug)
@@ -1469,7 +1501,7 @@
ast_verbose("Sending PacketSendQueryMacAddress\n");
memcpy(buffsend + SIZE_HEADER, PacketSendQueryMacAddress,
sizeof(PacketSendQueryMacAddress));
- SendClient(SIZE_HEADER + sizeof(PacketSendQueryMacAddress), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendQueryMacAddress), buffsend, pte);
return;
}
@@ -1533,7 +1565,7 @@
return 0;
}
-static void RcvMacAddr(struct unistimsession *pte, const unsigned char *buf)
+static void rcv_mac_addr(struct unistimsession *pte, const unsigned char *buf)
{
BUFFSEND;
int tmp, i = 0;
@@ -1670,40 +1702,40 @@
if (unistimdebug)
ast_verbose("\nSending S1\n");
memcpy(buffsend + SIZE_HEADER, PacketSendS1, sizeof(PacketSendS1));
- SendClient(SIZE_HEADER + sizeof(PacketSendS1), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendS1), buffsend, pte);
if (unistimdebug)
ast_verbose("Sending QueryBasicManager04\n");
memcpy(buffsend + SIZE_HEADER, PacketSendQueryBasicManager04,
sizeof(PacketSendQueryBasicManager04));
- SendClient(SIZE_HEADER + sizeof(PacketSendQueryBasicManager04), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendQueryBasicManager04), buffsend, pte);
if (unistimdebug)
ast_verbose("Sending QueryBasicManager10\n");
memcpy(buffsend + SIZE_HEADER, PacketSendQueryBasicManager10,
sizeof(PacketSendQueryBasicManager10));
- SendClient(SIZE_HEADER + sizeof(PacketSendQueryBasicManager10), buffsend, pte);
+ send_client(SIZE_HEADER + sizeof(PacketSendQueryBasicManager10), buffsend, pte);
SendDateTime(pte);
return;
}
-int WriteEntryHistory(struct unistimsession *pte, FILE * f, char c, char *line1)
+static int write_entry_history(struct unistimsession *pte, FILE * f, char c, char *line1)
{
if (fwrite(&c, 1, 1, f) != 1) {
- DisplayLastError("Unable to write history log header.");
+ display_last_error("Unable to write history log header.");
return -1;
}
if (fwrite(line1, TEXT_LENGTH_MAX, 1, f) != 1) {
- DisplayLastError("Unable to write history entry - date.");
+ display_last_error("Unable to write history entry - date.");
return -1;
}
if (fwrite(pte->device->lst_cid, TEXT_LENGTH_MAX, 1, f) != 1) {
- DisplayLastError("Unable to write history entry - callerid.");
+ display_last_error("Unable to write history entry - callerid.");
return -1;
}
if (fwrite(pte->device->lst_cnm, TEXT_LENGTH_MAX, 1, f) != 1) {
- DisplayLastError("Unable to write history entry - callername.");
+ display_last_error("Unable to write history entry - callername.");
return -1;
}
return 0;
@@ -1732,7 +1764,7 @@
snprintf(tmp, sizeof(tmp), "%s/%s", (char *) ast_config_AST_LOG_DIR, USTM_LOG_DIR);
if (mkdir(tmp, 0770)) {
if (errno != EEXIST) {
- DisplayLastError("Unable to create directory for history.");
+ display_last_error("Unable to create directory for history.");
return -1;
}
}
@@ -1754,7 +1786,7 @@
struct stat bufstat;
if (stat(tmp, &bufstat)) {
- DisplayLastError("Unable to stat history log.");
+ display_last_error("Unable to stat history log.");
fclose(f);
return -1;
}
@@ -1773,33 +1805,33 @@
int i;
if ((errno != ENOENT) && (count == 0)) {
- DisplayLastError("Unable to open history log.");
+ display_last_error("Unable to open history log.");
return -1;
}
f = fopen(tmp, "w");
if (!f) {
- DisplayLastError("Unable to create history log.");
+ display_last_error("Unable to create history log.");
return -1;
}
- if (WriteEntryHistory(pte, f, c, line1)) {
+ if (write_entry_history(pte, f, c, line1)) {
fclose(f);
return -1;
}
memset(line1, ' ', TEXT_LENGTH_MAX);
for (i = 3; i < MAX_ENTRY_LOG * 3; i++) {
if (fwrite(line1, TEXT_LENGTH_MAX, 1, f) != 1) {
- DisplayLastError("Unable to write history entry - stuffing.");
+ display_last_error("Unable to write history entry - stuffing.");
fclose(f);
return -1;
}
}
if (fclose(f))
- DisplayLastError("Unable to close history - creation.");
+ display_last_error("Unable to close history - creation.");
return 0;
}
/* We can open the log file, we create a temporary one, we add our entry and copy the rest */
if (fread(&count, 1, 1, f) != 1) {
- DisplayLastError("Unable to read history header.");
+ display_last_error("Unable to read history header.");
fclose(f);
return -1;
}
@@ -1813,14 +1845,14 @@
USTM_LOG_DIR, pte->device->name, way);
f2 = fopen(tmp2, "w");
if (!f2) {
- DisplayLastError("Unable to create temporary history log.");
+ display_last_error("Unable to create temporary history log.");
fclose(f);
return -1;
}
count++;
if (count > MAX_ENTRY_LOG)
count = MAX_ENTRY_LOG;
- if (WriteEntryHistory(pte, f2, count, line1)) {
+ if (write_entry_history(pte, f2, count, line1)) {
fclose(f);
fclose(f2);
return -1;
@@ -1836,34 +1868,34 @@
free(histbuf);
fclose(f);
fclose(f2);
- DisplayLastError("Unable to read previous history entries.");
+ display_last_error("Unable to read previous history entries.");
return -1;
}
if (fwrite(histbuf, size, 1, f2) != 1) {
free(histbuf);
[... 1281 lines stripped ...]
More information about the asterisk-commits
mailing list