~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
server/bulkcrypto.c (naclbox_decrypt): Trace calculated MAC tag.
[tripe]
/
server
/
peer.c
diff --git
a/server/peer.c
b/server/peer.c
index
308ab1d
..
f74b977
100644
(file)
--- a/
server/peer.c
+++ b/
server/peer.c
@@
-9,19
+9,18
@@
*
* This file is part of Trivial IP Encryption (TrIPE).
*
*
* This file is part of Trivial IP Encryption (TrIPE).
*
- * TrIPE 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, o
r
- *
(at your
option) any later version.
+ * TrIPE 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 3 of the License, or (at you
r
+ * option) any later version.
*
*
- * TrIPE 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 th
e
- *
GNU General Public License
for more details.
+ * TrIPE 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 Licens
e
+ * for more details.
*
* You should have received a copy of the GNU General Public License
*
* You should have received a copy of the GNU General Public License
- * along with TrIPE; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with TrIPE. If not, see <https://www.gnu.org/licenses/>.
*/
/*----- Header files ------------------------------------------------------*/
*/
/*----- Header files ------------------------------------------------------*/
@@
-204,10
+203,9
@@
static int p_decrypt(peer **pp, addr *a, size_t n,
p = q;
goto match;
}
p = q;
goto match;
}
- T( trace(T_PEER, "peer: failed to decrypt: try other mobile peers...",
- p_name(q)); )
+ T( trace(T_PEER, "peer: failed to decrypt: try other mobile peers..."); )
} else if (nmobile)
} else if (nmobile)
- T( trace(T_PEER, "peer: unknown source: trying mobile peers...")
; )
+ T( trace(T_PEER, "peer: unknown source: trying mobile peers...")
);
else {
p = 0;
goto searched;
else {
p = 0;
goto searched;
@@
-307,14
+305,14
@@
static void p_read(int fd, unsigned mode, void *v)
{
peer *p = 0;
addr a;
{
peer *p = 0;
addr a;
- s
ize
_t sz;
+ s
ocklen
_t sz;
ssize_t n;
int ch;
buf b, bb;
/* --- Read the data --- */
ssize_t n;
int ch;
buf b, bb;
/* --- Read the data --- */
-
TIMER
;
+
QUICKRAND
;
sz = sizeof(addr);
n = recvfrom(fd, buf_i, sizeof(buf_i), 0, &a.sa, &sz);
if (n < 0) {
sz = sizeof(addr);
n = recvfrom(fd, buf_i, sizeof(buf_i), 0, &a.sa, &sz);
if (n < 0) {
@@
-659,7
+657,7
@@
void p_tun(peer *p, buf *b)
{
buf *bb = p_txstart(p, MSG_PACKET);
{
buf *bb = p_txstart(p, MSG_PACKET);
-
TIMER
;
+
QUICKRAND
;
p_encrypt(p, MSG_PACKET, b, bb);
if (BOK(bb) && BLEN(bb)) {
p->st.n_ipout++;
p_encrypt(p, MSG_PACKET, b, bb);
if (BOK(bb) && BLEN(bb)) {
p->st.n_ipout++;
@@
-799,7
+797,7
@@
void p_init(struct in_addr addr, unsigned port)
unsigned p_port(void)
{
addr a;
unsigned p_port(void)
{
addr a;
- s
ize
_t sz = sizeof(addr);
+ s
ocklen
_t sz = sizeof(addr);
if (getsockname(sock.fd, &a.sa, &sz))
die(EXIT_FAILURE, "couldn't read port number: %s", strerror(errno));
if (getsockname(sock.fd, &a.sa, &sz))
die(EXIT_FAILURE, "couldn't read port number: %s", strerror(errno));
@@
-820,6
+818,7
@@
unsigned p_port(void)
static void p_keepalive(struct timeval *now, void *pv)
{
peer *p = pv;
static void p_keepalive(struct timeval *now, void *pv)
{
peer *p = pv;
+
p_txstart(p, MSG_MISC | MISC_NOP); p_dotxend(p);
T( trace(T_PEER, "peer: sent keepalive to %s", p->spec.name); )
p_setkatimer(p);
p_txstart(p, MSG_MISC | MISC_NOP); p_dotxend(p);
T( trace(T_PEER, "peer: sent keepalive to %s", p->spec.name); )
p_setkatimer(p);
@@
-871,8
+870,8
@@
peer *p_create(peerspec *spec)
T( trace(T_PEER, "peer: creating new peer `%s'", spec->name); )
p->spec = *spec;
p->spec.name = (/*unconst*/ char *)SYM_NAME(p->byname);
T( trace(T_PEER, "peer: creating new peer `%s'", spec->name); )
p->spec = *spec;
p->spec.name = (/*unconst*/ char *)SYM_NAME(p->byname);
- if (spec->tag)
-
p->spec.tag = xstrdup(spec->
tag);
+ if (spec->tag)
p->spec.tag = xstrdup(spec->tag);
+
if (spec->privtag) p->spec.privtag = xstrdup(spec->priv
tag);
p->ks = 0;
p->pings = 0;
p->ifname = 0;
p->ks = 0;
p->pings = 0;
p->ifname = 0;
@@
-902,8
+901,7
@@
peer *p_create(peerspec *spec)
return (p);
tidy_4:
return (p);
tidy_4:
- if (spec->t_ka)
- sel_rmtimer(&p->tka);
+ if (spec->t_ka) sel_rmtimer(&p->tka);
xfree(p->ifname);
p->t->ops->destroy(p->t);
tidy_3:
xfree(p->ifname);
p->t->ops->destroy(p->t);
tidy_3:
@@
-911,6
+909,7
@@
tidy_3:
tidy_2:
am_remove(&byaddr, p->byaddr);
if (p->spec.tag) xfree(p->spec.tag);
tidy_2:
am_remove(&byaddr, p->byaddr);
if (p->spec.tag) xfree(p->spec.tag);
+ if (p->spec.privtag) xfree(p->spec.privtag);
tidy_1:
sym_remove(&byname, p->byname);
tidy_0:
tidy_1:
sym_remove(&byname, p->byname);
tidy_0:
@@
-938,6
+937,16
@@
const char *p_name(peer *p)
const char *p_tag(peer *p)
{ return (p->spec.tag ? p->spec.tag : p->spec.name); }
const char *p_tag(peer *p)
{ return (p->spec.tag ? p->spec.tag : p->spec.name); }
+/* --- @p_privtag@ --- *
+ *
+ * Arguments: @peer *p@ = pointer to a peer block
+ *
+ * Returns: A pointer to the peer's private key tag.
+ */
+
+const char *p_privtag(peer *p)
+ { return (p->spec.privtag ? p->spec.privtag : tag_priv); }
+
/* --- @p_spec@ --- *
*
* Arguments: @peer *p@ = pointer to a peer block
/* --- @p_spec@ --- *
*
* Arguments: @peer *p@ = pointer to a peer block
@@
-1002,15
+1011,12
@@
void p_destroy(peer *p)
a_notify("KILL", "%s", p->spec.name, A_END);
ksl_free(&p->ks);
kx_free(&p->kx);
a_notify("KILL", "%s", p->spec.name, A_END);
ksl_free(&p->ks);
kx_free(&p->kx);
- if (p->spec.f & PSF_MOBILE)
- nmobile--;
- if (p->ifname)
- xfree(p->ifname);
- if (p->spec.tag)
- xfree(p->spec.tag);
+ if (p->spec.f & PSF_MOBILE) nmobile--;
+ if (p->ifname) xfree(p->ifname);
+ if (p->spec.tag) xfree(p->spec.tag);
+ if (p->spec.privtag) xfree(p->spec.privtag);
p->t->ops->destroy(p->t);
p->t->ops->destroy(p->t);
- if (p->spec.t_ka)
- sel_rmtimer(&p->tka);
+ if (p->spec.t_ka) sel_rmtimer(&p->tka);
for (pg = p->pings; pg; pg = ppg) {
ppg = pg->next;
p_pingdone(pg, PING_PEERDIED);
for (pg = p->pings; pg; pg = ppg) {
ppg = pg->next;
p_pingdone(pg, PING_PEERDIED);