Added mesh potato build script.

Updated gateway operation to support mesh potato again.
This commit is contained in:
gardners 2011-08-10 15:38:59 +02:00
parent ca09fcf104
commit 2f0307a08d
5 changed files with 41 additions and 5 deletions

9
dna.c
View File

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mphlr.h"
#include <stdarg.h>
char *gatewayuri=NULL;
char *gatewayspec=NULL;
char *outputtemplate=NULL;
char *instrumentation_file=NULL;
@ -215,7 +215,7 @@ int usage(char *complaint)
{
fprintf(stderr,"dna: %s\n",complaint);
fprintf(stderr,"usage:\n");
fprintf(stderr," dna [-v ...] -S <hlr size in MB> [-f HLR backing file] [-I import.txt] [-N interface,...] [-G SIP gateway]\n");
fprintf(stderr," dna [-v ...] -S <hlr size in MB> [-f HLR backing file] [-I import.txt] [-N interface,...] [-G gateway specification]\n");
fprintf(stderr,"or\n");
fprintf(stderr," dna [-v ...] -f <HLR backing file> -E <hlr export file>\n");
fprintf(stderr,"or\n");
@ -259,6 +259,8 @@ int usage(char *complaint)
fprintf(stderr," @value means read value from file called value.\n");
fprintf(stderr," -C - Request the creation of a new subscriber with the specified DID.\n");
fprintf(stderr," -t - Specify the request timeout period.\n");
fprintf(stderr," -G - Offer gateway services. Argument specifies locations of necessary files.\n");
fprintf(stderr," Use -G [potato|android|custom:...] to set defaults for your device type.\n");
fprintf(stderr," -N - Specify one or more interfaces for the DNA overlay mesh to operate.\n");
fprintf(stderr," Interface specifications take the form IP[:speed[:type[:port]]], and\n");
fprintf(stderr," multiple interfaces can be specified by comma separating them.\n");
@ -298,7 +300,8 @@ int main(int argc,char **argv)
overlayMode=1;
break;
case 'G': /* Offer gateway services */
gatewayuri=strdup(optarg);
gatewayspec=strdup(optarg);
if(prepareGateway(gatewayspec)) return usage("Invalid gateway specification");
break;
case 'E': /* Export HLR into plain text file that can be imported later */
if (!hlr_file) usage("You must specify an HLR file to export from, i.e., dna -f hlr.dat -E hlr.txt");

View File

@ -20,6 +20,33 @@ typedef struct dna_gateway_extension {
#define MAX_CURRENT_EXTENSIONS 1024
dna_gateway_extension extensions[MAX_CURRENT_EXTENSIONS];
int prepareGateway(char *spec)
{
if ((!strcasecmp(spec,"potato"))||(!strcasecmp(spec,"meshpotato"))||(!strcasecmp(spec,"mp"))||(!strcasecmp(spec,"mp1"))) {
/* Setup for mesh potato */
asterisk_extensions_conf="/etc/asterisk/gatewayextensions.conf";
asterisk_binary="/usr/sbin/asterisk";
temp_file="/var/dnatemp.out";
cmd_file="/var/dnatemp.cmd";
shell="/bin/sh";
return 0;
} else if ((!strcasecmp(spec,"android"))||(!strcasecmp(spec,"batphone"))) {
/* Setup for android -- this is default, so don't change anything */
return 0;
} else if (!strncasecmp(spec,"custom:",7)) {
char a[1024],b[1024],c[1024],d[1024],e[1024];
if (sscanf(spec,"custom:%[^:]:%[^:]:%[^:]:%[^:]:%[^:]",a,b,c,d,e)!=5) return WHY("Invalid custom gateway specification");
asterisk_extensions_conf=strdup(a);
asterisk_binary=strdup(b);
temp_file=strdup(c);
cmd_file=strdup(d);
shell=strdup(e);
return 0;
}
else
return WHY("Invalid gateway specification");
}
int safeSystem(char *cmd_file)
{
{

6
mpbuild Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
toolchain=$HOME/OpenWrt-SDK-atheros-for-Linux-i686/staging_dir/toolchain-mips_gcc4.1.2
$toolchain/bin/mips-linux-gcc -DHAVE_SYS_MMAN_H -DHAVE_STDINT_H -DHAVE_SYS_STAT_H -DHAVE_POLL_H -DHAVE_ARPA_INET_H -DHAVE_BZERO -o dna.meshpotato `ls -1 *.c | egrep -v "asterisk_app.c|serval.c"`
$toolchain/bin/mips-linux-strip dna.meshpotato

View File

@ -125,7 +125,7 @@ double simulatedBER;
extern int serverMode;
extern char *gatewayuri;
extern char *gatewayspec;
extern struct sockaddr recvaddr;
extern struct in_addr client_addr;

View File

@ -420,7 +420,7 @@ int processRequest(unsigned char *packet,int len,
data[dlen++]=sendDone&0xff;
respondSimple(hlr_sid,ACTION_DATA,data,dlen,transaction_id,CRYPT_CIPHERED|CRYPT_SIGNED);
}
if (gatewayuri&&(var_id==VAR_LOCATIONS)&&did&&strlen(did))
if (gatewayspec&&(var_id==VAR_LOCATIONS)&&did&&strlen(did))
{
/* We are a gateway, so offer connection via the gateway as well */
unsigned char data[MAX_DATA_BYTES+16];