From: Mark Wooding Date: Wed, 11 Jul 2007 22:21:17 +0000 (+0100) Subject: Use the new official IANA-allocated port number 4070. X-Git-Tag: 1.0.0pre8~81 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/commitdiff_plain/165efde7f48706c6b4680aa537b3467e70d6a11d Use the new official IANA-allocated port number 4070. This is now the default port selected by the server (say -p0 for explicit dynamic allocation). Also let the ADDR command default to 4070 so that nobody needs to remember it. --- diff --git a/README b/README index e3e83425..1a9e12e3 100644 --- a/README +++ b/README @@ -45,7 +45,7 @@ Installation notes #! /bin/sh set -e - tripectl add PEER PEER-ADDR 22003 + tripectl add PEER PEER-ADDR 4070 ifname=`tripectl ifname PEER` ifconfig $ifname LOCAL pointopoint REMOTE mtu 1429 route add -net RNET netmask RMASK gw REMOTE diff --git a/common/protocol.h b/common/protocol.h index 1fc15118..88de6307 100644 --- a/common/protocol.h +++ b/common/protocol.h @@ -31,6 +31,8 @@ /*----- TrIPE protocol ----------------------------------------------------*/ +#define TRIPE_PORT 4070 /* Assigned by IANA */ + /* --- TrIPE message format --- * * * A packet begins with a single-byte message type. The top four bits are a diff --git a/debian/tripe.README b/debian/tripe.README index 8f87cf6e..810069df 100644 --- a/debian/tripe.README +++ b/debian/tripe.README @@ -40,7 +40,7 @@ SETTING UP TRIPE FOR DEBIAN GNU/LINUX PEER=... # The peer's name PEERADDR=... # Peer's publicly-routable address - PEERPORT=22003 # Port peer is listening on + PEERPORT=4070 # Port peer is listening on LOCAL=... # My address for point-to-point REMOTE=... # His address for point-to-point RNET=... # Remote network address diff --git a/doc/tripe-admin.5.in b/doc/tripe-admin.5.in index 7fb59c3e..968400e7 100644 --- a/doc/tripe-admin.5.in +++ b/doc/tripe-admin.5.in @@ -215,12 +215,13 @@ are always in upper-case. .PP At present, only one address family is understood. .TP -.BI "INET " address " " port +.BI "INET " address " \fR[" port \fR] An Internet socket, naming an IPv4 address and UDP port. On output, the address is always in numeric dotted-quad form, and the port is given as a plain number. On input, DNS hostnames and symbolic port names are -permitted. Name resolution does not block the main server, but will -block the requesting client, unless the command is run in the background. +permitted; if omitted, the default port 4070 is used. Name resolution +does not block the main server, but will block the requesting client, +unless the command is run in the background. .PP If, on input, no recognised address family token is found, the following words are assumed to represent an diff --git a/doc/tripe.8.in b/doc/tripe.8.in index b287673a..52df1d0c 100644 --- a/doc/tripe.8.in +++ b/doc/tripe.8.in @@ -364,18 +364,12 @@ Start the servers up. Run .RS .VS -tripectl \-slD \-S\-p22003 +tripectl \-slD .VE on each of .B alice and .BR bob . -(The -.RB ` \-p22003 ' -forces the server to use UDP port 22003: use some other number if 22003 -is inappropriate for your requirements. I chose it by taking the first -16 bits of the RIPEMD160 hash of -.RB ` TrIPE '. .RE .hP 6. To get @@ -387,7 +381,7 @@ run this shell script (or one like it): .VS #! /bin/sh -tripectl add bob 200.0.2.1 22003 +tripectl add bob 200.0.2.1 4070 ifname=`tripectl ifname bob` ifconfig $ifname 10.0.1.1 pointopoint 10.0.2.1 route add -net \e diff --git a/init/tripe.conf b/init/tripe.conf index 8105a2a1..19f061bf 100644 --- a/init/tripe.conf +++ b/init/tripe.conf @@ -18,12 +18,11 @@ # packets from the named address. The latter is probably more useful. # addr=MYHOST -# The UDP port you want tripe to use. I've chosen 22003 which isn't reserved -# in any way. I chose it because it's the first two bytes of the RIPEMD-160 -# hash of the string `TrIPE'. If you don't set a port, tripe gets the kernel -# to choose a port it's not using right now, and you have to dig it out by -# saying `tripectl port'. -# port=22003 +# The UDP port you want tripe to use. The default is 4070, which is +# officially allocated by the IANA. If you explicitly specify port 0 +# then tripe gets the kernel to choose a port it's not using right now, +# and you have to dig it out by saying `tripectl port'. +# port=4070 # The tunnel device you want tripe to use. The default is to use a system- # specific device, if there's one compiled in, or SLIP if not. diff --git a/mon/tripemon.in b/mon/tripemon.in index 4d0472a6..912f7d0b 100644 --- a/mon/tripemon.in +++ b/mon/tripemon.in @@ -966,7 +966,7 @@ class AddPeerDialog (MyDialog): newlinep = True) me.e_port = table.labelled('Port', ValidatingEntry(numericvalidate(0, 65535), - '22003', + '4070', 5)) me.c_keepalive = G.CheckButton('Keepalives') me.l_tunnel = table.labelled('Tunnel', diff --git a/server/admin.c b/server/admin.c index ecf222fd..55ed82b3 100644 --- a/server/admin.c +++ b/server/admin.c @@ -1059,21 +1059,25 @@ static void a_resolve(admin *a, admin_resop *r, const char *tag, r->addr = 0; r->func = func; if (mystrieq(av[i], "inet")) i++; - if (ac - i != 2) { - a_fail(a, "bad-addr-syntax", "[inet] ADDRESS PORT", A_END); + if (ac - i != 1 && ac - i != 2) { + a_fail(a, "bad-addr-syntax", "[inet] ADDRESS [PORT]", A_END); goto fail; } r->sa.sin.sin_family = AF_INET; r->sasz = sizeof(r->sa.sin); r->addr = xstrdup(av[i]); - pt = strtoul(av[i + 1], &p, 0); - if (*p) { - struct servent *s = getservbyname(av[i + 1], "udp"); - if (!s) { - a_fail(a, "unknown-service", "%s", av[i + 1], A_END); - goto fail; + if (!av[i + i]) + pt = TRIPE_PORT; + else { + pt = strtoul(av[i + 1], &p, 0); + if (*p) { + struct servent *s = getservbyname(av[i + 1], "udp"); + if (!s) { + a_fail(a, "unknown-service", "%s", av[i + 1], A_END); + goto fail; + } + pt = ntohs(s->s_port); } - pt = ntohs(s->s_port); } if (pt == 0 || pt >= 65536) { a_fail(a, "invalid-port", "%lu", pt, A_END); diff --git a/server/tripe.c b/server/tripe.c index 670e1410..f46e232c 100644 --- a/server/tripe.c +++ b/server/tripe.c @@ -114,7 +114,8 @@ Options:\n\ -D, --daemon Run in the background.\n\ -d, --directory=DIR Switch to directory DIR [default " CONFIGDIR "].\n\ -b, --bind-address=ADDR Bind UDP socket to this IP ADDR.\n\ --p, --port=PORT Select UDP port to listen to.\n\ +-p, --port=PORT Select UDP port to listen to " + "[default " STR(TRIPE_PORT) "].\n\ -n, --tunnel=TUNNEL Seelect default tunnel driver.\n\ -U, --setuid=USER Set uid to USER after initialization.\n\ -G, --setgid=GROUP Set gid to GROUP after initialization.\n\ @@ -135,7 +136,7 @@ int main(int argc, char *argv[]) const char *csock = SOCKETDIR "/tripesock"; const char *dir = CONFIGDIR; const char *p; - unsigned port = 0; + unsigned port = TRIPE_PORT; struct in_addr baddr = { INADDR_ANY }; unsigned f = 0; int i; @@ -243,7 +244,7 @@ int main(int argc, char *argv[]) die(EXIT_FAILURE, "unknown service name `%s'", optarg); i = ntohs(s->s_port); } - if (i == 0 || i >= 65536) + if (i >= 65536) die(EXIT_FAILURE, "bad port number %lu", i); port = i; } break; diff --git a/server/tripe.h b/server/tripe.h index 3db1cb96..cc8a4e6f 100644 --- a/server/tripe.h +++ b/server/tripe.h @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include diff --git a/wireshark/packet-tripe.c b/wireshark/packet-tripe.c index 798ccd9e..e3daae7c 100644 --- a/wireshark/packet-tripe.c +++ b/wireshark/packet-tripe.c @@ -468,7 +468,7 @@ void proto_reg_handoff_tripe(void) dissector_handle_t dh; dh = create_dissector_handle(dissect_tripe, proto_tripe); - dissector_add("udp.port", 22003, dh); + dissector_add("udp.port", TRIPE_PORT, dh); } G_MODULE_EXPORT void plugin_reg_handoff(void)