diff options
Diffstat (limited to 'packages/gsm')
-rw-r--r-- | packages/gsm/files/gsmd | 6 | ||||
-rw-r--r-- | packages/gsm/files/install-ts-headers.patch | 11 | ||||
-rw-r--r-- | packages/gsm/gsmd.inc | 87 | ||||
-rw-r--r-- | packages/gsm/libgsmd-devel_svn.bb | 22 | ||||
-rw-r--r-- | packages/gsm/libgsmd_svn.bb | 77 | ||||
-rw-r--r-- | packages/gsm/pty/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/gsm/pty/pty.c | 163 | ||||
-rw-r--r-- | packages/gsm/pty_0.0.bb | 16 |
8 files changed, 304 insertions, 78 deletions
diff --git a/packages/gsm/files/gsmd b/packages/gsm/files/gsmd index 0ac4698899..9257b901ad 100644 --- a/packages/gsm/files/gsmd +++ b/packages/gsm/files/gsmd @@ -1,4 +1,4 @@ -##!/bin/sh +#! /bin/sh # # gsmd This shell script starts and stops gsmd. # @@ -37,13 +37,11 @@ case "$1" in restart|force-reload) $0 stop $0 start - exit ;; *) - echo "Usage: /etc/init.d/apmd {start|stop|restart|force-reload}" + echo "Usage: /etc/init.d/gsmd {start|stop|restart|force-reload}" exit 1 ;; esac exit 0 - diff --git a/packages/gsm/files/install-ts-headers.patch b/packages/gsm/files/install-ts-headers.patch new file mode 100644 index 0000000000..88e3b6dd1f --- /dev/null +++ b/packages/gsm/files/install-ts-headers.patch @@ -0,0 +1,11 @@ +Index: gsm/include/gsmd/Makefile.am +=================================================================== +--- gsm.orig/include/gsmd/Makefile.am 2007-10-29 21:05:57.000000000 +0100 ++++ gsm/include/gsmd/Makefile.am 2007-10-29 21:06:03.000000000 +0100 +@@ -1,4 +1,4 @@ + +-pkginclude_HEADERS = event.h usock.h ++pkginclude_HEADERS = event.h ts0705.h ts0707.h usock.h + +-noinst_HEADERS = atcmd.h gsmd.h select.h ts0705.h ts0707.h unsolicited.h usock.h vendorplugin.h ++noinst_HEADERS = atcmd.h gsmd.h select.h unsolicited.h usock.h vendorplugin.h diff --git a/packages/gsm/gsmd.inc b/packages/gsm/gsmd.inc new file mode 100644 index 0000000000..4fe36b9616 --- /dev/null +++ b/packages/gsm/gsmd.inc @@ -0,0 +1,87 @@ +DESCRIPTION = "GSM libraries and daemons implementing the 07.10 specification" +HOMEPAGE = "http://www.openmoko.org" +LICENSE = "GPL LGPL" +SECTION = "libs/gsm" +PROVIDES += "gsmd" +RPROVIDES_${PN} = "libgsmd0 libgsmd gsmd gsmd-devel" +PV = "0.1+svnr${SRCREV}" +PR = "r37" + +SRC_URI = "svn://svn.openmoko.org/trunk/src/target;module=gsm;proto=http \ + file://gsmd \ + file://default" +S = "${WORKDIR}/gsm" + +inherit autotools pkgconfig update-rc.d +# handle update-rc.d RDEPENDS manually, we don't need it on +# anything but gsmd +RDEPENDS_append = "" + +INITSCRIPT_NAME = "gsmd" +INITSCRIPT_PARAMS = "defaults 35" + +do_stage() { + autotools_stage_all +} + +do_install_append() { + install -d ${D}/${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/gsmd ${D}/${sysconfdir}/init.d/ + install -d ${D}/${sysconfdir}/default + install ${WORKDIR}/default ${D}/${sysconfdir}/default/gsmd +} + +PACKAGES =+ "${PN}-tools \ + ${BASEPN}-plugins \ + ${BASEPN}-plugin-machine-generic \ + ${BASEPN}-plugin-machine-tihtc \ + ${BASEPN}-plugin-vendor-bcm \ + ${BASEPN}-plugin-vendor-qc \ + ${BASEPN}-plugin-vendor-ti \ + ${BASEPN}-plugin-vendor-tihtc \ + " + +RDEPENDS_${BASEPN}-plugins = "${BASEPN}-plugin-machine-generic \ + ${BASEPN}-plugin-machine-tihtc \ + ${BASEPN}-plugin-vendor-bcm \ + ${BASEPN}-plugin-vendor-qc \ + ${BASEPN}-plugin-vendor-ti \ + ${BASEPN}-plugin-vendor-tihtc \ + " + +RDEPENDS_${PN} += "update-rc.d initscripts" +RRECOMMENDS_${PN} += "${BASEPN}-plugins" + +FILES_${PN}-dbg += "${libdir}/gsmd/.debug/*" +FILES_${PN}-tools = "${bindir}/*" +FILES_${BASEPN}-plugins = "" +FILES_${BASEPN}-plugin-machine-generic = "${libdir}/gsmd/libgsmd-machine_generic.so*" +FILES_${BASEPN}-plugin-machine-tihtc = "${libdir}/gsmd/libgsmd-machine_tihtc.so*" +FILES_${BASEPN}-plugin-vendor-qc = "${libdir}/gsmd/libgsmd-vendor_qc.so*" +FILES_${BASEPN}-plugin-vendor-bcm = "${libdir}/gsmd/libgsmd-vendor_bcm.so*" +FILES_${BASEPN}-plugin-vendor-ti = "${libdir}/gsmd/libgsmd-vendor_ti.so*" +FILES_${BASEPN}-plugin-vendor-tihtc = "${libdir}/gsmd/libgsmd-vendor_tihtc.so*" + +PACKAGES_DYNAMIC = "lib${BASEPN}* ${BASEPN}" + +ALLOW_EMPTY_${BASEPN}-plugins = "1" + +RCONFLICTS_lib${BASEPN} = "lib${CONFLICTNAME}" +RCONFLICTS_${BASEPN} = "${CONFLICTNAME}" +RCONFLICTS_${BASEPN}-plugins = "${CONFLICTNAME}-plugins" +RCONFLICTS_${BASEPN}-plugin-machine-generic = "${CONFLICTNAME}-plugin-machine-generic" +RCONFLICTS_${BASEPN}-plugin-machine-tihtc = "${CONFLICTNAME}-plugin-machine-tihtc" +RCONFLICTS_${BASEPN}-plugin-vendor-qc = "${CONFLICTNAME}-plugin-vendor-qc" +RCONFLICTS_${BASEPN}-plugin-vendor-bcm = "${CONFLICTNAME}-plugin-vendor-bcm" +RCONFLICTS_${BASEPN}-plugin-vendor-ti = "${CONFLICTNAME}-plugin-vendor-ti" +RCONFLICTS_${BASEPN}-plugin-vendor-tihtc = "${CONFLICTNAME}-plugin-vendor-tihtc" + +RPROVIDES_lib${BASEPN} += "lib${CONFLICTNAME}" +RPROVIDES_${BASEPN} = "${CONFLICTNAME}" +RPROVIDES_${BASEPN}-plugins = "${CONFLICTNAME}-plugins" +RPROVIDES_${BASEPN}-plugin-machine-generic = "${CONFLICTNAME}-plugin-machine-generic" +RPROVIDES_${BASEPN}-plugin-machine-tihtc = "${CONFLICTNAME}-plugin-machine-tihtc" +RPROVIDES_${BASEPN}-plugin-vendor-qc = "${CONFLICTNAME}-plugin-vendor-qc" +RPROVIDES_${BASEPN}-plugin-vendor-bcm = "${CONFLICTNAME}-plugin-vendor-bcm" +RPROVIDES_${BASEPN}-plugin-vendor-ti = "${CONFLICTNAME}-plugin-vendor-ti" +RPROVIDES_${BASEPN}-plugin-vendor-tihtc = "${CONFLICTNAME}-plugin-vendor-tihtc" diff --git a/packages/gsm/libgsmd-devel_svn.bb b/packages/gsm/libgsmd-devel_svn.bb new file mode 100644 index 0000000000..d584e88d38 --- /dev/null +++ b/packages/gsm/libgsmd-devel_svn.bb @@ -0,0 +1,22 @@ +BASEPN = "gsmd-devel" +CONFLICTNAME = "gsmd" + +require gsmd.inc + +PROVIDES += "libgsmd" +RPROVIDES_${PN}-tools = "lib${CONFLICTNAME}-tools" + +SRC_URI += " file://024_sms-text-in-bracket.patch;patch=1;minrev=2957;maxrev=3199 \ + file://025_sms-status-report.patch;patch=1;minrev=2957;maxrev=3200 \ + file://027_phonebook-find-and-read-range-support.patch;patch=1;minrev=2957;maxrev=3202 \ + file://028_shell-phonebook-find-and-read-range-support.patch;patch=1;minrev=2957;maxrev=3203 \ + file://0001-Introduce-ports.patch;patch=1;minrev=2957 \ + file://0002-Flush-all-pending-commands-before-restarting-the-mod.patch;patch=1;minrev=2957 \ + file://0003-Correctly-segment-incoming-usock-data-into-packets.patch;patch=1;minrev=2957 \ + file://0004-Handle-read-and-write-return-values.patch;patch=1;minrev=2957 \ + file://0005-Add-ask-ds-option-forSMS.patch;patch=1;minrev=2957;maxrev=3201 \ + file://lgsm_send_fix_return_value.patch;patch=1;maxrev=3266 \ + file://install-ts-headers.patch;patch=1 \ + file://gsmd \ + file://default" + diff --git a/packages/gsm/libgsmd_svn.bb b/packages/gsm/libgsmd_svn.bb index e07b4acfa9..9d3ca19c04 100644 --- a/packages/gsm/libgsmd_svn.bb +++ b/packages/gsm/libgsmd_svn.bb @@ -1,76 +1,5 @@ -DESCRIPTION = "GSM libraries and daemons implementing the 07.10 specification" -HOMEPAGE = "http://www.openmoko.org" -LICENSE = "GPL LGPL" -SECTION = "libs/gsm" -PROVIDES += "gsmd" -PV = "0.1+svnr${SRCREV}" -PR = "r31" +BASEPN = "gsmd" +CONFLICTNAME = "gsmd-devel" -SRC_URI = "svn://svn.openmoko.org/trunk/src/target;module=gsm;proto=http \ - file://024_sms-text-in-bracket.patch;patch=1;minrev=2957;maxrev=3199 \ - file://025_sms-status-report.patch;patch=1;minrev=2957;maxrev=3200 \ - file://027_phonebook-find-and-read-range-support.patch;patch=1;minrev=2957;maxrev=3202 \ - file://028_shell-phonebook-find-and-read-range-support.patch;patch=1;minrev=2957;maxrev=3203 \ - file://0001-Introduce-ports.patch;patch=1;minrev=2957 \ - file://0002-Flush-all-pending-commands-before-restarting-the-mod.patch;patch=1;minrev=2957 \ - file://0003-Correctly-segment-incoming-usock-data-into-packets.patch;patch=1;minrev=2957 \ - file://0004-Handle-read-and-write-return-values.patch;patch=1;minrev=2957 \ - file://0005-Add-ask-ds-option-forSMS.patch;patch=1;minrev=2957;maxrev=3201 \ - file://lgsm_send_fix_return_value.patch;patch=1 \ - file://gsmd \ - file://default" -S = "${WORKDIR}/gsm" +require gsmd.inc -inherit autotools pkgconfig update-rc.d -# handle update-rc.d RDEPENDS manually, we don't need it on -# anything but gsmd -RDEPENDS_append = "" - -INITSCRIPT_NAME = "gsmd" -INITSCRIPT_PARAMS = "defaults 35" - -do_stage() { - autotools_stage_all -} - -do_install_append() { - install -d ${D}/${sysconfdir}/init.d - install -m 0755 ${WORKDIR}/gsmd ${D}/${sysconfdir}/init.d/ - install -d ${D}/${sysconfdir}/default - install ${WORKDIR}/default ${D}/${sysconfdir}/default/gsmd -} - -PACKAGES =+ "${PN}-tools gsmd gsmd-plugins \ - gsmd-plugin-machine-generic gsmd-plugin-machine-tihtc \ - gsmd-plugin-vendor-bcm \ - gsmd-plugin-vendor-qc \ - gsmd-plugin-vendor-ti \ - gsmd-plugin-vendor-tihtc \ - " - -RDEPENDS_${PN} = "gsmd" -RDEPENDS_gsmd-plugins = "gsmd-plugin-machine-generic \ - gsmd-plugin-machine-tihtc \ - gsmd-plugin-vendor-bcm \ - gsmd-plugin-vendor-qc \ - gsmd-plugin-vendor-ti \ - gsmd-plugin-vendor-tihtc \ - " - -RDEPENDS_gsmd = "update-rc.d initscripts" -RRECOMMENDS_gsmd = "gsmd-plugins" - -FILES_${PN}-dbg += "${libdir}/gsmd/.debug/*" -FILES_${PN}-tools = "${bindir}/*" -FILES_gsmd = "${sbindir}/gsmd ${sysconfdir}" -FILES_gsmd-plugins = "" -FILES_gsmd-plugin-machine-generic = "${libdir}/gsmd/libgsmd-machine_generic.so*" -FILES_gsmd-plugin-machine-tihtc = "${libdir}/gsmd/libgsmd-machine_tihtc.so*" -FILES_gsmd-plugin-vendor-qc = "${libdir}/gsmd/libgsmd-vendor_qc.so*" -FILES_gsmd-plugin-vendor-bcm = "${libdir}/gsmd/libgsmd-vendor_bcm.so*" -FILES_gsmd-plugin-vendor-ti = "${libdir}/gsmd/libgsmd-vendor_ti.so*" -FILES_gsmd-plugin-vendor-tihtc = "${libdir}/gsmd/libgsmd-vendor_tihtc.so*" - -PACKAGES_DYNAMIC = "libgsmd* gsmd" - -ALLOW_EMPTY_gsmd-plugins = "1" diff --git a/packages/gsm/pty/.mtn2git_empty b/packages/gsm/pty/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/gsm/pty/.mtn2git_empty diff --git a/packages/gsm/pty/pty.c b/packages/gsm/pty/pty.c new file mode 100644 index 0000000000..4a33d0efd3 --- /dev/null +++ b/packages/gsm/pty/pty.c @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2007 OpenedHand, Ltd. + * Contact: <andrew@o-hand.com> + * + * This file is licensed under the terms of GNU GPL v2. + * + * $ pty [<hostname|ip> <port>] + * Opens a new pseudo terminal and forwards data between standard input + * and the pty and between the pty and standard output. If a hostname and + * port number are given, reads and writes to the socket instead of + * standard input or output. Path to the slave pty is printed on standard + * error. + */ +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> +#include <poll.h> + +#define CHECK(val, name) \ + if (val == -1) { \ + fprintf(stderr, #name ": %s (%i)\n", strerror(errno), errno);\ + return -errno; \ + } + +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +static int forward2(int in0, int out0, int in1, int out1, + int (*closed)(int fd)) { + int inpos = 0, inlen = 0, outpos = 0, outlen = 0, ret, n; + fd_set rfds, wfds; + char in[0x100], out[0x100]; + + n = max(max(in0, in1), max(out0, out1)) + 1; + while (1) { + FD_ZERO(&rfds); + FD_ZERO(&wfds); + if (inlen < sizeof(in)) + FD_SET(in0, &rfds); + if (outlen < sizeof(out)) + FD_SET(in1, &rfds); + if (inlen) + FD_SET(out0, &wfds); + if (outlen) + FD_SET(out1, &wfds); + CHECK(select(n, &rfds, &wfds, 0, 0), select); + + if (FD_ISSET(in0, &rfds)) { + ret = (inpos + inlen) & (sizeof(in) - 1); + ret = read(in0, in + ret, + sizeof(in) - max(ret, inlen)); + CHECK(ret, read(0)); + if (!ret) + return 0; + inlen += ret; + } + if (FD_ISSET(in1, &rfds)) { + ret = (outpos + outlen) & (sizeof(out) - 1); + ret = read(in1, out + ret, + sizeof(out) - max(ret, outlen)); + if (ret > 0) + outlen += ret; + if (ret < 0 && errno == EIO && closed) { + in1 = out0 = closed(in1); + if (in1 < 0) + return in1; + n = max(max(in0, in1), max(out0, out1)) + 1; + continue; + } + } + if (FD_ISSET(out0, &wfds)) { + ret = write(out0, in + inpos, + min(sizeof(in) - inpos, inlen)); + CHECK(ret, write(pty)); + inlen -= ret; + inpos += ret; + inpos &= sizeof(in) - 1; + } + if (FD_ISSET(out1, &wfds)) { + ret = write(out1, out + outpos, + min(sizeof(out) - outpos, outlen)); + CHECK(ret, write(1)); + outlen -= ret; + outpos += ret; + outpos &= sizeof(out) - 1; + } + } + + return pause(); +} + +static int reopen(int fd) { + const char *name = ttyname(fd); + + CHECK(close(fd), close(pty)); + fd = open(name, O_RDWR | O_NOCTTY); + CHECK(fd, open); + CHECK(grantpt(fd), grantpt); + CHECK(unlockpt(fd), unlockpt); + + fprintf(stderr, "%s\n", ptsname(fd)); + return fd; +} + +int main(int argc, char *argv[], char **envp) { + int sock, fd; + struct sockaddr_in sa; + struct hostent *hi; + + fd = posix_openpt(O_RDWR | O_NOCTTY); + CHECK(fd, open); + CHECK(grantpt(fd), grantpt); + CHECK(unlockpt(fd), unlockpt); + + fprintf(stderr, "%s\n", ptsname(fd)); +#if 0 + /* Connect stdin & stdout with a pty */ + CHECK(close(0), close(0)); + CHECK(close(1), close(1)); + CHECK(dup(fd), dup(0)); + CHECK(dup(fd), dup(1)); + return pause(); +#endif + if (argc != 3) + return forward2(0, fd, fd, 1, reopen); + +#if 0 + /* Connect a sub-process with a pty */ + for (len = 0, i = 1; i < argc; i ++) + len += strlen(argv[i]) + 4; + param = malloc(len); + strcpy(param, argv[1]); + for (i = 2; i < argc; i ++) + sprintf(param + strlen(param), " \"%s\"", argv[i]); + i = fileno(popen(param, O_RDWR)); + CHECK(i, popen); + free(param); + return forward2(i, fd, fd, i, reopen); +#endif + + /* Connect a TCP socket with a pty */ + hi = gethostbyname(argv[1]); + if (!hi) { + errno = h_errno; + CHECK(-1, gethostbyname); + } + sa.sin_family = hi->h_addrtype; + memcpy(&sa.sin_addr.s_addr, hi->h_addr_list[0], hi->h_length); + sa.sin_port = htons(strtol(argv[2], 0, 0)); + sock = socket(AF_INET, SOCK_STREAM, 0); + + CHECK(sock, socket); + CHECK(connect(sock, (struct sockaddr *) &sa, sizeof(sa)), connect); + return forward2(sock, fd, fd, sock, reopen); +} diff --git a/packages/gsm/pty_0.0.bb b/packages/gsm/pty_0.0.bb new file mode 100644 index 0000000000..39592a90a1 --- /dev/null +++ b/packages/gsm/pty_0.0.bb @@ -0,0 +1,16 @@ +DESCRIPTION = "Forwards a socket to a tty" +LICENSE = "GPLv2" +PR = "r1" + +SRC_URI = "file://pty.c" + +do_compile() { + cp ${WORKDIR}/*.c ${S}/ + ${CC} pty.c -o pty -I${STAGING_INCDIR} -L${STAGING_LIBDIR} +} + +do_install() { + install -d ${D}${bindir} + install -m 0755 pty ${D}${bindir}/ +} + |