initial commit (with submodule)

This commit is contained in:
Dan Bastone 2021-10-29 14:41:03 -04:00 committed by Jerry
commit 740ef1bfbf
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
33 changed files with 11760 additions and 0 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "pjproject"]
path = pjproject
url = https://github.com/pjsip/pjproject

339
COPYING Normal file
View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

26
Makefile Normal file
View file

@ -0,0 +1,26 @@
PJSIP_DIR=pjproject-2.11.1
PKG_CONFIG_PATH=pjsip.install/lib/pkgconfig
all: d-modem slmodemd
$(PKG_CONFIG_PATH)/libpjproject.pc:
(cd $(PJSIP_DIR); [ -f ./config.status ] || ./configure --prefix=`pwd`/../pjsip.install --disable-video)
$(MAKE) -C $(PJSIP_DIR) && \
$(MAKE) -C $(PJSIP_DIR) install
d-modem: d-modem.c $(PKG_CONFIG_PATH)/libpjproject.pc
$(CC) -o $@ $< `PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" pkg-config --static --cflags --libs libpjproject`
slmodemd:
$(MAKE) -C slmodemd
clean:
rm -f d-modem.o d-modem
$(MAKE) -C slmodemd clean
realclean: clean
$(MAKE) -C $(PJSIP_DIR) realclean
rm -rf pjsip.install/*
.PHONY: all clean realclean slmodemd

71
README.md Normal file
View file

@ -0,0 +1,71 @@
# D-Modem
Connect to dialup modems over VoIP using SIP, no modem hardware required.
https://www.aon.com/cyber-solutions/aon_cyber_labs/introducing-d-modem-a-software-sip-modem/
## Building
You'll need Linux and a working 32-bit development environment (gcc -m32 needs to work, Debian-based systems can install libc6-dev-i386), along with PJSIP's dependencies (OpenSSL). Then run 'make' from the top-level directory.
## How it Works
Traditional “controller-based” modems generally used a microcontroller and a DSP to handle all aspects of modem communication on the device itself. Later, so-called “Winmodems” were introduced that allowed for field-programmable DSPs and moved the controller and other functionality into software running on the host PC. This was followed by “pure software” modems that moved DSP functionality to the host as well. The physical hardware of these softmodems was only used to connect to the phone network, and all processing was done in software.
D-Modem replaces a softmodems physical hardware with a SIP stack. Instead of passing audio to and from the software DSP over an analog phone line, audio travels via the RTP (or SRTP) media streams of a SIP VoIP call.
## Usage
The repository contains two applications:
slmodemd A stripped down and patched version of Debians sl-modem-daemon package. All kernel driver code has been replaced with socket-based communication, allowing external applications to manage audio streams.
d-modem External application that interfaces with slmodemd to manage SIP calls and their associated audio streams.
After they have been built, you will need to configure SIP account information in the SIP_LOGIN environment variable:
# export SIP_LOGIN=username:password@sip.example.com
Next, run slmodemd, passing the path to d-modem in the -e option. Use -d<level> for debug logging.
# ./slmodemd/slmodemd -d9 -e ./d-modem
SmartLink Soft Modem: version 2.9.11 Oct 28 2021 16:51:30
symbolic link `/dev/ttySL0' -> `/dev/pts/3' created.
modem `slamr0' created. TTY is `/dev/pts/3'
Use `/dev/ttySL0' as modem device, Ctrl+C for termination.
In another terminal, connect to the newly created serial device at 115200 bps:
# screen /dev/ttySL0 115200
You can now interact with this terminal (almost) as you would with a normal modem using standard AT commands. A similar modems manual provides a more complete list.
Because there isnt any dial tone on our SIP connection, youll need to disable dial tone detection:
atx3
OK
To successfully connect, you will likely need to manually select a modulation and data rate. In our testing, V.32bis (14.4kbps) and below appears to be the most reliable, though V.34 (33.6kbps) connections are sometimes successful. For example, the following command selects V.32bis with a data rate of 4800 9600 bps. Refer to the manual for further details.
at+ms=132,0,4800,9600
OK
Finally, dial the number of the target system. Below shows a connection to the NIST atomic clock:
atd303-494-4774
CONNECT 9600
National Institute of Standards and Technology
Telephone Time Service, Generator 1b
Enter the question mark character for HELP
D L
MJD YR MO DA HH MM SS ST S UT1 msADV <OTM>
59515 21-10-28 21:40:18 11 0 -.1 045.0 UTC(NIST) *
59515 21-10-28 21:40:19 11 0 -.1 045.0 UTC(NIST) *
59515 21-10-28 21:40:20 11 0 -.1 045.0 UTC(NIST) *
59515 21-10-28 21:40:21 11 0 -.1 045.0 UTC(NIST) *
59515 21-10-28 21:40:22 11 0 -.1 045.0 UTC(NIST) *
59515 21-10-28 21:40:23 11 0 -.1 045.0 UTC(NIST) *
## Known Issues / Future Work
- Connections are unreliable, and it is currently difficult to connect at speeds higher than 14.4kbps or so. It might be possible to improve this by disabling/reconfiguring PJSIPs jitter buffer.
- Additional logging/error handling is needed
- The serial interface could be replaced with stdio or a socket, and common AT configuration options could be exposed as command line options
- There is currently no support for receiving calls
Copyright 2021 Aon plc

262
d-modem.c Normal file
View file

@ -0,0 +1,262 @@
/*
* Copyright (C) 2021 Aon plc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <unistd.h>
#include <stdbool.h>
#include <time.h>
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <pjsua-lib/pjsua.h>
#define SIGNATURE PJMEDIA_SIG_CLASS_PORT_AUD('D','M')
struct dmodem {
pjmedia_port base;
pj_timestamp timestamp;
pj_sock_t sock;
};
static struct dmodem port;
static bool destroying = false;
static pj_pool_t *pool;
static void error_exit(const char *title, pj_status_t status) {
pjsua_perror(__FILE__, title, status);
if (!destroying) {
destroying = true;
pjsua_destroy();
exit(1);
}
}
static pj_status_t dmodem_put_frame(pjmedia_port *this_port, pjmedia_frame *frame) {
struct dmodem *sm = (struct dmodem *)this_port;
int len;
if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) {
if ((len=write(sm->sock, frame->buf, frame->size)) != frame->size) {
error_exit("error writing frame",0);
}
}
return PJ_SUCCESS;
}
static pj_status_t dmodem_get_frame(pjmedia_port *this_port, pjmedia_frame *frame) {
struct dmodem *sm = (struct dmodem *)this_port;
frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info); // MAX? what is
int len;
if ((len=read(sm->sock, frame->buf, frame->size)) != frame->size) {
error_exit("error reading frame",0);
}
frame->timestamp.u64 = sm->timestamp.u64;
frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
sm->timestamp.u64 += PJMEDIA_PIA_SPF(&this_port->info);
return PJ_SUCCESS;
}
static pj_status_t dmodem_on_destroy(pjmedia_port *this_port) {
printf("destroy\n");
exit(-1);
}
/* Callback called by the library when call's state has changed */
static void on_call_state(pjsua_call_id call_id, pjsip_event *e) {
pjsua_call_info ci;
PJ_UNUSED_ARG(e);
pjsua_call_get_info(call_id, &ci);
PJ_LOG(3,(__FILE__, "Call %d state=%.*s", call_id,
(int)ci.state_text.slen,
ci.state_text.ptr));
if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
close(port.sock);
if (!destroying) {
destroying = true;
pjsua_destroy();
exit(0);
}
}
}
/* Callback called by the library when call's media state has changed */
static void on_call_media_state(pjsua_call_id call_id) {
pjsua_call_info ci;
pjsua_conf_port_id port_id;
static int done=0;
pjsua_call_get_info(call_id, &ci);
// printf("media_status %d media_cnt %d ci.conf_slot %d aud.conf_slot %d\n",ci.media_status,ci.media_cnt,ci.conf_slot,ci.media[0].stream.aud.conf_slot);
if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
if (!done) {
pjsua_conf_add_port(pool, &port.base, &port_id);
pjsua_conf_connect(ci.conf_slot, port_id);
pjsua_conf_connect(port_id, ci.conf_slot);
done = 1;
}
} else {
done = 0;
}
}
int main(int argc, char *argv[]) {
pjsua_acc_id acc_id;
pj_status_t status;
if (argc != 3) {
return -1;
}
signal(SIGPIPE,SIG_IGN);
char *dialstr = argv[1];
char *sip_user = getenv("SIP_LOGIN");
if (!sip_user) {
return -1;
}
char *sip_domain = strchr(sip_user,'@');
if (!sip_domain) {
return -1;
}
*sip_domain++ = '\0';
char *sip_pass = strchr(sip_user,':');
if (!sip_pass) {
return -1;
}
*sip_pass++ = '\0';
status = pjsua_create();
if (status != PJ_SUCCESS) error_exit("Error in pjsua_create()", status);
/* Init pjsua */
{
pjsua_config cfg;
pjsua_logging_config log_cfg;
pjsua_media_config med_cfg;
pjsua_config_default(&cfg);
cfg.cb.on_call_media_state = &on_call_media_state;
cfg.cb.on_call_state = &on_call_state;
pjsua_logging_config_default(&log_cfg);
log_cfg.console_level = 4;
pjsua_media_config_default(&med_cfg);
med_cfg.no_vad = true;
med_cfg.ec_tail_len = 0;
med_cfg.jb_max = 2000;
// med_cfg.jb_init = 200;
med_cfg.audio_frame_ptime = 5;
status = pjsua_init(&cfg, &log_cfg, &med_cfg);
if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status);
}
pjsua_set_ec(0,0); // maybe?
pjsua_set_null_snd_dev();
/* g711 only */
pjsua_codec_info codecs[32];
unsigned count = sizeof(codecs)/sizeof(*codecs);
pjsua_enum_codecs(codecs,&count);
for (int i=0; i<count; i++) {
int pri = 0;
if (pj_strcmp2(&codecs[i].codec_id,"PCMU/8000/1") == 0) {
pri = 1;
} else if (pj_strcmp2(&codecs[i].codec_id,"PCMA/8000/1") == 0) {
pri = 2;
}
pjsua_codec_set_priority(&codecs[i].codec_id, pri);
// printf("codec: %s %d\n",pj_strbuf(&codecs[i].codec_id),pri);
}
/* Add UDP transport. */
{
pjsua_transport_config cfg;
pjsua_transport_config_default(&cfg);
cfg.port = 5060;
status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
}
pj_caching_pool cp;
pj_caching_pool_init(&cp, NULL, 1024*1024);
pool = pj_pool_create(&cp.factory, "pool1", 4000, 4000, NULL);
pj_str_t name = pj_str("dmodem");
memset(&port,0,sizeof(port));
port.sock = atoi(argv[2]); // inherited from parent
pjmedia_port_info_init(&port.base.info, &name, SIGNATURE, 9600, 1, 16, 192);
port.base.put_frame = dmodem_put_frame;
port.base.get_frame = dmodem_get_frame;
port.base.on_destroy = dmodem_on_destroy;
char buf[384];
memset(buf,0,sizeof(buf));
write(port.sock, buf, sizeof(buf));
/* Initialization is done, now start pjsua */
status = pjsua_start();
if (status != PJ_SUCCESS) error_exit("Error starting pjsua", status);
{
pjsua_acc_config cfg;
pjsua_acc_config_default(&cfg);
snprintf(buf,sizeof(buf),"sip:%s@%s",sip_user,sip_domain);
pj_strdup2(pool,&cfg.id,buf);
snprintf(buf,sizeof(buf),"sip:%s",sip_domain);
pj_strdup2(pool,&cfg.reg_uri,buf);
cfg.register_on_acc_add = false;
cfg.cred_count = 1;
cfg.cred_info[0].realm = pj_str("*");
cfg.cred_info[0].scheme = pj_str("digest");
cfg.cred_info[0].username = pj_str(sip_user);
cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
cfg.cred_info[0].data = pj_str(sip_pass);
status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
if (status != PJ_SUCCESS) error_exit("Error adding account", status);
}
snprintf(buf,sizeof(buf),"sip:%s@%s",dialstr,sip_domain);
printf("calling %s\n",buf);
pj_str_t uri = pj_str(buf);
pjsua_call_id callid;
status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, &callid);
if (status != PJ_SUCCESS) error_exit("Error making call", status);
struct timespec ts = {100, 0};
while(1) {
nanosleep(&ts,NULL);
}
return 0;
}

1
pjproject Submodule

@ -0,0 +1 @@
Subproject commit 43c745789d291496fe1c3ed8a2c0dd6305260b32

34
slmodemd/COPYING Normal file
View file

@ -0,0 +1,34 @@
/*
*
* Copyright (c) 2001, Smart Link Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. Neither the name of the Smart Link Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/

92
slmodemd/Makefile Normal file
View file

@ -0,0 +1,92 @@
###########################################################################
#
#
# Makefile -- modem application Makefile.
#
# Copyright(c) 2003, Smart Link Ltd. (www.smlink.com)
# All rights reserved.
#
# Author: Sasha K (sashak@smlink.com)
#
#
###########################################################################
#
###########################################################################
ARCH64:=$(shell uname -m | sed -e '/amd64/s//x86_64/' | grep -c x86_64)
ifeq ($(ARCH64), 0)
CC:= gcc
else
# SUPPORT_ALSA:=1
CC:= gcc -m32
endif
RM:= rm -f
CFLAGS+= -Wall -g -O -I. -DCONFIG_DEBUG_MODEM
modem-objs:= \
modem.o modem_datafile.o modem_at.o modem_timer.o \
modem_pack.o modem_ec.o modem_comp.o \
modem_param.o modem_debug.o homolog_data.o
dp-objs:= dp_sinus.o dp_dummy.o
sysdep-objs:= sysdep_common.o
all-objs:= modem_cmdline.o $(modem-objs) $(dp-objs) dsplibs.o $(sysdep-objs)
all: slmodemd modem_test
slmodemd: modem_main.o $(all-objs)
modem_test: modem_test.o $(all-objs)
ifdef SUPPORT_ALSA
CFLAGS+= -DSUPPORT_ALSA=1
ifeq ($(ARCH64), 0)
LFLAGS+= /usr/lib/libasound.so
else
# LFLAGS+= /usr/lib32/libasound.so , replaced by -l commands search for asound
LFLAGS+= -lasound
endif
endif
slmodemd:
$(CC) -o slmodemd modem_main.o $(all-objs) $(LFLAGS)
modem_test:
$(CC) -o modem_test modem_test.o $(all-objs) $(LFLAGS)
clean:
$(RM) slmodemd modem_test modem_main.o modem_cmdline.o modem_test.o $(modem-objs) $(dp-objs) $(sysdep-objs)
$(RM) *~ *.orig *.rej
.PHONY: all dep generic-dep clean clean-build-profile
#
# rules
#
%.o: %.c .build_profile
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -o $@ -c $<
dep: generic-dep
generic-dep:
$(RM) .depend
$(foreach src,$(wildcard *.c),$(CC) -M $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(src:.c=.o)) -c $(src) >> .depend ;)
-include .depend
# build_profile
-include .build_profile
.build_profile::
ifneq ($(CFLAGS),$(PROFILE_CFLAGS))
@if [ "$(CFLAGS) $(EXTRA_CFLAGS)" != "$(PROFILE_CFLAGS)" ] ; then \
echo "rebuild profile..." ; \
echo "PROFILE_CFLAGS=$(CFLAGS) $(EXTRA_CFLAGS)" > $(@) ; fi
endif
clean: clean-build-profile
clean-build-profile:
@$(RM) -f .build_profile

View file

@ -0,0 +1,92 @@
###########################################################################
#
#
# Makefile -- modem application Makefile.
#
# Copyright(c) 2003, Smart Link Ltd. (www.smlink.com)
# All rights reserved.
#
# Author: Sasha K (sashak@smlink.com)
#
#
###########################################################################
#
###########################################################################
ARCH64:=$(shell uname -m | sed -e '/amd64/s//x86_64/' | grep -c x86_64)
ifeq ($(ARCH64), 0)
CC:= gcc
else
# SUPPORT_ALSA:=1
CC:= gcc -m32
endif
RM:= rm -f
CFLAGS+= -Wall -g -O -I. -DCONFIG_DEBUG_MODEM
modem-objs:= \
modem.o modem_datafile.o modem_at.o modem_timer.o \
modem_pack.o modem_ec.o modem_comp.o \
modem_param.o modem_debug.o homolog_data.o
dp-objs:= dp_sinus.o dp_dummy.o
sysdep-objs:= sysdep_common.o
all-objs:= modem_cmdline.o $(modem-objs) $(dp-objs) dsplibs.o $(sysdep-objs)
all: slmodemd modem_test
slmodemd: modem_main.o $(all-objs)
modem_test: modem_test.o $(all-objs)
ifdef SUPPORT_ALSA
CFLAGS+= -DSUPPORT_ALSA=1
ifeq ($(ARCH64), 0)
LFLAGS+= /usr/lib/libasound.so
else
# LFLAGS+= /usr/lib32/libasound.so , replaced by -l commands search for asound
LFLAGS+= -lasound
endif
endif
slmodemd:
$(CC) -o slmodemd modem_main.o $(all-objs) $(LFLAGS)
modem_test:
$(CC) -o modem_test modem_test.o $(all-objs) $(LFLAGS)
clean:
$(RM) slmodemd modem_test modem_main.o modem_cmdline.o modem_test.o $(modem-objs) $(dp-objs) $(sysdep-objs)
$(RM) *~ *.orig *.rej
.PHONY: all dep generic-dep clean clean-build-profile
#
# rules
#
%.o: %.c .build_profile
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -o $@ -c $<
dep: generic-dep
generic-dep:
$(RM) .depend
$(foreach src,$(wildcard *.c),$(CC) -M $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(src:.c=.o)) -c $(src) >> .depend ;)
-include .depend
# build_profile
-include .build_profile
.build_profile::
ifneq ($(CFLAGS),$(PROFILE_CFLAGS))
@if [ "$(CFLAGS) $(EXTRA_CFLAGS)" != "$(PROFILE_CFLAGS)" ] ; then \
echo "rebuild profile..." ; \
echo "PROFILE_CFLAGS=$(CFLAGS) $(EXTRA_CFLAGS)" > $(@) ; fi
endif
clean: clean-build-profile
clean-build-profile:
@$(RM) -f .build_profile

153
slmodemd/dp_dummy.c Normal file
View file

@ -0,0 +1,153 @@
/*
*
* Copyright (c) 2002, Smart Link Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. Neither the name of the Smart Link Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
*
* dp_dummy.c -- dummy data pump (very stupid simulator).
*
* Author: Sasha K (sashak@smlink.com)
*
*
*/
#include <modem.h>
#include <modem_debug.h>
#define DUMMY_SKIP 100
#define DUMMY_TIMEOUT 300
#define DUMMY_A1 0xff
struct dummy_dp {
struct dp dp;
unsigned long count;
unsigned long linked;
u8 buf[1024];
void *dcr;
};
static struct dp *dummy_create(struct modem *m, enum DP_ID id,
int caller, int srate, int max_frag,
struct dp_operations *op)
{
struct dummy_dp *d;
dprintf("dummy_create...\n");
d = malloc(sizeof(*d));
memset(d,0,sizeof(*d));
d->dp.id = id;
d->dp.modem = m;
d->dp.op = op;
d->dp.dp_data = d;
d->dcr = m->dcr;
m->dcr = NULL;
return (struct dp *)d;
}
static int dummy_delete(struct dp *dp)
{
struct dummy_dp *d = (struct dummy_dp *)dp;
dprintf("dummy_delete...\n");
dp->modem->dcr = d->dcr;
free(d);
return 0;
}
static int dummy_process(struct dp *dp, void *in, void *out, int cnt)
{
struct dummy_dp *d = (struct dummy_dp *)dp;
int n = cnt << MFMT_SHIFT(dp->modem->format);
s16 *s;
int i;
d->count++;
if (!d->linked) {
if (d->count < DUMMY_SKIP) {
memset(out,0,n);
return DPSTAT_OK;
}
else if(d->count > DUMMY_TIMEOUT)
return DPSTAT_ERROR;
s = out;
for(i = 0 ; i < cnt ; i++) {
*s = (1-2*(i&1))*('A');
s++;
}
s = in;
for(i = 0 ; i < cnt ; i++) {
if(abs(*s) == 'A') {
d->linked = 1;
return DPSTAT_CONNECT;
}
s++;
}
}
else {
s = in;
for(i = 0 ; i < cnt ; i++) {
d->buf[i] = *s&0x1;
s++;
}
modem_put_bits(dp->modem,1,d->buf,cnt);
s = out;
modem_get_bits(dp->modem,1,d->buf,cnt);
for(i = 0 ; i < cnt ; i++) {
*s = d->buf[i]&1 ;
s++;
}
}
return DPSTAT_OK;
}
static struct dp_operations dummy_operations = {
name : "Dummy DataPump driver",
create: dummy_create,
delete: dummy_delete,
process:dummy_process
};
int dp_dummy_init(void)
{
return modem_dp_register(DP_DUMMY,&dummy_operations);
}
void dp_dummy_exit(void)
{
modem_dp_deregister(DP_DUMMY,&dummy_operations);
}

133
slmodemd/dp_sinus.c Normal file
View file

@ -0,0 +1,133 @@
/*
*
* Copyright (c) 2002, Smart Link Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. Neither the name of the Smart Link Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
*
* sinus.c -- sinus data pump.
*
* Author: Sasha K (sashak@smlink.com)
*
*
*/
#include <modem.h>
#include <modem_debug.h>
#ifdef __KERNEL__
#define malloc(size) kmalloc(size,GFP_KERNEL)
#define free(mem) kfree(mem)
#endif
#define SIN_AMPLITUDE 16384
#define SIN_PERIOD (sizeof(sintab)/sizeof(sintab[0]))
static
const s16 sintab[] = {
0, 3196, 6269, 9102, 11585, 13622, 15136, 16069,
16384, 16069, 15136, 13622, 11585, 9102, 6269, 3196,
0, -3196, -6269, -9102, -11585, -13622, -15136, -16069,
-16384, -16069, -15136, -13622, -11585, -9102, -6269, -3196};
#define SIN_DBG(fmt,arg...) dprintf("sin: " fmt , ##arg)
struct sin_state {
struct dp dp;
int count;
int linked;
u8 buf[1024];
int amp;
unsigned period;
unsigned phase;
};
static struct dp *sin_create(struct modem *m, enum DP_ID id,
int caller, int srate, int max_frag,
struct dp_operations *op)
{
struct sin_state *s;
SIN_DBG("create...\n");
s = malloc(sizeof(*s));
if (!s) return NULL;
memset(s,0,sizeof(*s));
s->dp.id = id;
s->dp.modem = m;
s->dp.op = op;
s->dp.dp_data = s;
s->phase = 0;
s->amp = SIN_AMPLITUDE;
s->period= SIN_PERIOD;
return &s->dp;
}
static int sin_delete(struct dp *dp)
{
struct sin_state *s = dp->dp_data;
SIN_DBG("delete...\n");
free(s);
return 0;
}
static int sin_run(struct dp *dp, void *in, void *out, int cnt)
{
struct sin_state *s = dp->dp_data;
s16 *smpl = out;
int i;
//SIN_DBG("run...\n");
for (i=0;i<cnt;i++) {
smpl[i] = sintab[s->phase%SIN_PERIOD];
s->phase = s->phase+1;
}
return DPSTAT_OK;
}
static struct dp_operations sin_operations = {
name : "Sinus DP driver",
create: sin_create,
delete: sin_delete,
process:sin_run
};
int dp_sinus_init(void)
{
return modem_dp_register(DP_SINUS,&sin_operations);
}
void dp_sinus_exit(void)
{
modem_dp_deregister(DP_SINUS,&sin_operations);
}

BIN
slmodemd/dsplibs.o Normal file

Binary file not shown.

131
slmodemd/homolog_data.c Normal file
View file

@ -0,0 +1,131 @@
/* generated at Jun 1 2004 19:11:22 */
#include <modem.h>
#include <modem_homolog.h>
static const struct homolog_params params000 = {0x22,0x43,0x01,0x08,0x5a,0x28,0x3f,0x02,0x25,0x3f,0x00,0x1b,0x02,0x09,0x01,0x10,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params001 = {0x24,0x40,0x01,0x06,0x64,0x12,0x3c,0x04,0x12,0x3c,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x05,0x2b,0x00,0xff,0x06,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params002 = {0x21,0x43,0x01,0x08,0x5a,0x23,0x27,0x04,0x23,0x27,0x00,0x09,0x02,0x09,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params003 = {0x28,0x3c,0x01,0x08,0x5a,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x04,0x09,0x01,0x08,0x02,0x06,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params005 = {0x21,0x43,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x0c,0x04,0x09,0x01,0x07,0x02,0x04,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params006 = {0x24,0x40,0x01,0x06,0x64,0x12,0x50,0x04,0x12,0x50,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x05,0x2b,0x00,0xff,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params007 = {0x21,0x43,0x01,0x06,0x69,0x2a,0x50,0x04,0x2a,0x50,0x00,0x3c,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x03,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params008 = {0x28,0x3c,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params011 = {0x24,0x40,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params012 = {0x21,0x43,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params013 = {0x21,0x43,0x01,0x08,0x5a,0x2a,0x50,0x04,0x2a,0x50,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params014 = {0x28,0x3c,0x01,0x06,0x5a,0x06,0x2a,0x08,0x0d,0x3c,0x01,0x0a,0x04,0x09,0x01,0x0e,0x02,0x00,0x22,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params015 = {0x24,0x40,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x09,0x02,0x09,0x01,0x19,0x02,0x00,0x26,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params016 = {0x21,0x43,0x01,0x09,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params018 = {0x28,0x3c,0x01,0x08,0x5a,0x0a,0x42,0x04,0x0a,0x41,0x00,0x09,0x04,0x09,0x01,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params020 = {0x29,0x3c,0x01,0x08,0x5a,0x0f,0x3c,0x04,0x23,0x3c,0x00,0x12,0x04,0x09,0x01,0x19,0x02,0x05,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params022 = {0x24,0x40,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x06,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params023 = {0x21,0x43,0x01,0x06,0x5a,0x0b,0x3c,0x02,0x0b,0x3c,0x00,0x09,0x04,0x09,0x01,0x08,0x02,0x06,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params025 = {0x24,0x40,0x01,0x06,0x64,0x41,0x55,0x04,0x41,0x55,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x2e,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params027 = {0x22,0x43,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x04,0x09,0x00,0x19,0x02,0x02,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params028 = {0x24,0x40,0x01,0x06,0x64,0x12,0x3c,0x04,0x12,0x3c,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x05,0x2b,0x00,0xff,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params029 = {0x29,0x41,0x01,0x08,0x5a,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x02,0x09,0x01,0x0f,0x02,0x04,0x28,0x00,0x1e,0x00,0x50,0x06,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params030 = {0x22,0x42,0x01,0x08,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x0e,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params032 = {0x22,0x42,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x08,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x06,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params033 = {0x24,0x40,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x00,0x2b,0x00,0xff,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params035 = {0x21,0x43,0x01,0x08,0x5a,0x21,0x30,0x04,0x0e,0x19,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params036 = {0x28,0x3c,0x01,0x06,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x04,0x09,0x01,0x19,0x02,0x05,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params038 = {0x21,0x43,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x03,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params039 = {0x21,0x43,0x01,0x08,0x5a,0x21,0x3c,0x04,0x21,0x3c,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params040 = {0x24,0x40,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x32,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x2e,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params041 = {0x21,0x43,0x01,0x06,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params042 = {0x28,0x3c,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x0b,0x02,0x09,0x01,0x0f,0x02,0x07,0x20,0x00,0x1e,0x00,0x50,0x05,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params043 = {0x21,0x43,0x03,0x07,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x46,0x04,0x09,0x00,0x19,0x01,0x01,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params044 = {0x24,0x40,0x01,0x08,0x5a,0x0a,0x42,0x02,0x0a,0x41,0x00,0x0a,0x04,0x09,0x01,0x0f,0x02,0x00,0x27,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params045 = {0x21,0x43,0x01,0x08,0x69,0x00,0x00,0x04,0x00,0x00,0x00,0x09,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x03,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params049 = {0x21,0x43,0x01,0x06,0x5a,0x0b,0x3c,0x02,0x0b,0x3c,0x00,0x09,0x04,0x09,0x01,0x08,0x02,0x05,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params050 = {0x21,0x43,0x01,0x08,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x14,0x02,0x09,0x01,0x19,0x02,0x03,0x23,0x01,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params051 = {0x28,0x3c,0x01,0x07,0x5a,0x0c,0x16,0x04,0x0c,0x16,0x00,0x12,0x04,0x09,0x01,0x19,0x02,0x05,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params052 = {0x26,0x3e,0x01,0x04,0x69,0x22,0x2e,0x04,0x22,0x2e,0x00,0x09,0x02,0x0a,0x00,0x19,0x03,0x01,0x2b,0x00,0x1e,0x00,0x32,0x03,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params054 = {0x21,0x43,0x01,0x07,0x69,0x48,0x4e,0x04,0x48,0x4e,0x00,0x09,0x02,0x0a,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x03,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params055 = {0x28,0x3c,0x01,0x07,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x0a,0x04,0x09,0x01,0x19,0x02,0x05,0x2b,0x00,0x1e,0x00,0x55,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params056 = {0x28,0x3c,0x01,0x07,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x12,0x04,0x09,0x01,0x19,0x02,0x05,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params057 = {0x28,0x3c,0x01,0x09,0x5a,0x2a,0x50,0x04,0x2a,0x50,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params059 = {0x21,0x43,0x01,0x08,0x5a,0x05,0x3c,0x04,0x05,0x3c,0x00,0x0a,0x05,0x09,0x01,0x0c,0x02,0x05,0x29,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params061 = {0x28,0x3c,0x02,0x08,0x5a,0x14,0x1e,0x04,0x14,0x55,0x00,0x09,0x04,0x09,0x01,0x0f,0x02,0x00,0x1f,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params062 = {0x28,0x3c,0x01,0x08,0x5a,0x08,0x50,0x02,0x08,0x50,0x00,0x0c,0x04,0x09,0x01,0x0f,0x02,0x00,0x25,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x01,};
static const struct homolog_params params063 = {0x21,0x43,0x01,0x06,0x64,0x14,0x3c,0x04,0x14,0x3c,0x00,0x32,0x02,0x0a,0x00,0x0a,0x02,0x01,0x2b,0x00,0x1e,0x06,0x50,0x03,0x00,0x00,0x00,0x012c,0x00,};
static const struct homolog_params params064 = {0x28,0x3c,0x01,0x06,0x64,0x00,0x00,0x04,0x00,0x00,0x00,0x09,0x02,0x0a,0x00,0x19,0x02,0x01,0x23,0x00,0x1e,0x00,0x50,0x02,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params067 = {0x21,0x43,0x01,0x07,0x5a,0x00,0x00,0x04,0x00,0x00,0x00,0x07,0x04,0x09,0x00,0x02,0x02,0x03,0x2d,0x00,0x1e,0x00,0x15,0x04,0x00,0x00,0x00,0x029a,0x00,};
static const struct homolog_params params068 = {0x22,0x48,0x01,0x08,0x5a,0x23,0x27,0x04,0x23,0x27,0x00,0x07,0x04,0x09,0x00,0x19,0x02,0x01,0x2b,0x00,0x1e,0x00,0x50,0x04,0x00,0x00,0x00,0x029a,0x00,};
const struct homolog_set homolog_set[] = {
{0x0002,"ALGERIA",&params000},
{0x0007,"ARGENTINA",&params001},
{0x0009,"AUSTRALIA",&params002},
{0x000a,"AUSTRIA",&params003},
{0x000c,"BAHREIN",&params001},
{0x000f,"BELGIUM",&params005},
{0x0016,"BRAZIL",&params006},
{0x001a,"BRUNEI",&params007},
{0x001b,"BULGARIA",&params008},
{0x0020,"CANADA",&params001},
{0x0025,"CHILE",&params001},
{0x0026,"CHINA",&params011},
{0x0100,"CTR21EUROPE",&params012},
{0x002d,"CYPRUS",&params013},
{0x002e,"CZECH_REPUBLIC",&params014},
{0x0031,"DENMARK",&params015},
{0x0036,"EGYPT",&params016},
{0x0101,"ESTONIA",&params012},
{0x003c,"FINLAND",&params018},
{0x003d,"FRANCE",&params000},
{0x0042,"GERMANY",&params020},
{0x0046,"GREECE",&params012},
{0x0050,"HONG_KONG",&params022},
{0x0051,"HUNGARY",&params023},
{0x0052,"ICELAND",&params012},
{0x0053,"INDIA",&params025},
{0x0054,"INDONESIA",&params011},
{0x0057,"IRELAND",&params027},
{0x0058,"ISRAEL",&params028},
{0x0059,"ITALY",&params029},
{0x0000,"JAPAN",&params030},
{0x005e,"JORDAN",&params013},
{0x0061,"KOREA",&params032},
{0x0062,"KUWAIT",&params033},
{0x0103,"LATVIA",&params008},
{0x0064,"LEBANON",&params035},
{0x0104,"LITHUANIA",&params036},
{0x0069,"LUXEMBOURG",&params012},
{0x006c,"MALAYSIA",&params038},
{0x0070,"MALTA",&params039},
{0x0073,"MEXICO",&params040},
{0x0077,"MOROCCO",&params041},
{0x007b,"NETHERLANDS",&params042},
{0x007e,"NEW_ZEALAND",&params043},
{0x0082,"NORWAY",&params044},
{0x0083,"OMAN",&params045},
{0x0084,"PAKISTAN",&params040},
{0x0088,"PERU",&params001},
{0x0089,"PHILIPPINES",&params040},
{0x008a,"POLAND",&params049},
{0x008b,"PORTUGAL",&params050},
{0x008e,"ROMANIA",&params051},
{0x00b8,"RUSSIA",&params052},
{0x0098,"SAUDIARABIA",&params001},
{0x009c,"SINGAPORE",&params054},
{0x00c5,"SLOVAKIA",&params055},
{0x00c6,"SLOVENIA",&params056},
{0x009f,"SOUTHAFRICA",&params057},
{0x0107,"SOUTHKOREA",&params001},
{0x00a0,"SPAIN",&params059},
{0x00a1,"SRILANKA",&params054},
{0x00a5,"SWEDEN",&params061},
{0x00a6,"SWITZERLAND",&params062},
{0x0108,"TAIWAN",&params063},
{0x00a9,"THAILAND",&params064},
{0x00ad,"TUNISIA",&params000},
{0x00ae,"TURKEY",&params012},
{0x00b3,"UAE",&params067},
{0x00b4,"UK",&params068},
{0x00b7,"URUGUAY",&params001},
{0x00b5,"USA",&params001},
{0x00bc,"VIETNAM",&params040},
{}};

1973
slmodemd/modem.c Normal file

File diff suppressed because it is too large Load diff

460
slmodemd/modem.h Normal file
View file

@ -0,0 +1,460 @@
/*
*
* Copyright (c) 2002, Smart Link Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. Neither the name of the Smart Link Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
*
* modem.h - modem definitions
*
* Author: sashak@smlink.com
*/
#ifndef __MODEM_H__
#define __MODEM_H__
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <termios.h>
#include <modem_defs.h>
#include <modem_homolog.h>
#include <modem_dp.h>
#include <modem_timer.h>