version 1.1, 2012/02/21 23:32:47
|
version 1.1.1.3, 2021/03/17 00:39:23
|
Line 68
|
Line 68
|
static void EcpRecvResetReq(Fsm fp, int id, Mbuf bp); |
static void EcpRecvResetReq(Fsm fp, int id, Mbuf bp); |
static void EcpRecvResetAck(Fsm fp, int id, Mbuf bp); |
static void EcpRecvResetAck(Fsm fp, int id, Mbuf bp); |
|
|
static int EcpSetCommand(Context ctx, int ac, char *av[], void *arg); | static int EcpSetCommand(Context ctx, int ac, const char *const av[], const void *arg); |
static EncType EcpFindType(int type, int *indexp); |
static EncType EcpFindType(int type, int *indexp); |
static const char *EcpTypeName(int type); |
static const char *EcpTypeName(int type); |
|
|
Line 94
|
Line 94
|
EcpSetCommand, NULL, 2, (void *) SET_YES }, |
EcpSetCommand, NULL, 2, (void *) SET_YES }, |
{ "no [opt ...]", "Disable and deny option", |
{ "no [opt ...]", "Disable and deny option", |
EcpSetCommand, NULL, 2, (void *) SET_NO }, |
EcpSetCommand, NULL, 2, (void *) SET_NO }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
/* |
/* |
Line 141
|
Line 141
|
EcpFailure, |
EcpFailure, |
EcpRecvResetReq, |
EcpRecvResetReq, |
EcpRecvResetAck, |
EcpRecvResetAck, |
|
NULL, NULL, NULL, NULL |
}; |
}; |
|
|
/* Names for different types of encryption */ |
/* Names for different types of encryption */ |
Line 161
|
Line 162
|
|
|
int gEcpCsock = -1; /* Socket node control socket */ |
int gEcpCsock = -1; /* Socket node control socket */ |
int gEcpDsock = -1; /* Socket node data socket */ |
int gEcpDsock = -1; /* Socket node data socket */ |
EventRef gEcpDataEvent; | static EventRef gEcpDataEvent; |
|
|
int |
int |
EcpsInit(void) |
EcpsInit(void) |
Line 214 EcpInit(Bund b)
|
Line 215 EcpInit(Bund b)
|
if (gConfList == NULL) |
if (gConfList == NULL) |
{ |
{ |
struct confinfo *ci; |
struct confinfo *ci; |
int k; | unsigned k; |
|
|
ci = Malloc(MB_CRYPT, (ECP_NUM_PROTOS + 1) * sizeof(*ci)); |
ci = Malloc(MB_CRYPT, (ECP_NUM_PROTOS + 1) * sizeof(*ci)); |
for (k = 0; k < ECP_NUM_PROTOS; k++) |
for (k = 0; k < ECP_NUM_PROTOS; k++) |
Line 251 EcpConfigure(Fsm fp)
|
Line 252 EcpConfigure(Fsm fp)
|
{ |
{ |
Bund b = (Bund)fp->arg; |
Bund b = (Bund)fp->arg; |
EcpState const ecp = &b->ecp; |
EcpState const ecp = &b->ecp; |
int k; | unsigned k; |
|
|
for (k = 0; k < ECP_NUM_PROTOS; k++) |
for (k = 0; k < ECP_NUM_PROTOS; k++) |
{ |
{ |
Line 275 EcpUnConfigure(Fsm fp)
|
Line 276 EcpUnConfigure(Fsm fp)
|
{ |
{ |
Bund b = (Bund)fp->arg; |
Bund b = (Bund)fp->arg; |
EcpState const ecp = &b->ecp; |
EcpState const ecp = &b->ecp; |
int k; | unsigned k; |
|
|
for (k = 0; k < ECP_NUM_PROTOS; k++) |
for (k = 0; k < ECP_NUM_PROTOS; k++) |
{ |
{ |
Line 302 EcpNgDataEvent(int type, void *cookie)
|
Line 303 EcpNgDataEvent(int type, void *cookie)
|
socklen_t nsize; |
socklen_t nsize; |
Mbuf bp; |
Mbuf bp; |
int num = 0; |
int num = 0; |
char *bundname, *rest; | char *bundname, *rest, *b1; |
int id; |
int id; |
|
|
|
(void)type; |
|
(void)cookie; |
while (1) { |
while (1) { |
/* Protect from bundle shutdown and DoS */ |
/* Protect from bundle shutdown and DoS */ |
if (num > 100) |
if (num > 100) |
Line 326 EcpNgDataEvent(int type, void *cookie)
|
Line 329 EcpNgDataEvent(int type, void *cookie)
|
|
|
/* Debugging */ |
/* Debugging */ |
LogDumpBp(LG_FRAME, bp, |
LogDumpBp(LG_FRAME, bp, |
"EcpNgDataEvent: rec'd %d bytes frame on %s hook", MBLEN(bp), naddr.sg_data); | "EcpNgDataEvent: rec'd %zu bytes frame on %s hook", MBLEN(bp), naddr.sg_data); |
|
|
bundname = ((struct sockaddr_ng *)&naddr)->sg_data; |
bundname = ((struct sockaddr_ng *)&naddr)->sg_data; |
if (bundname[0] != 'e' && bundname[0] != 'd') { |
if (bundname[0] != 'e' && bundname[0] != 'd') { |
Line 335 EcpNgDataEvent(int type, void *cookie)
|
Line 338 EcpNgDataEvent(int type, void *cookie)
|
mbfree(bp); |
mbfree(bp); |
continue; |
continue; |
} |
} |
|
/* Keep old value */ |
|
b1 = bundname; |
bundname++; |
bundname++; |
id = strtol(bundname, &rest, 10); |
id = strtol(bundname, &rest, 10); |
if (rest[0] != 0 || !gBundles[id] || gBundles[id]->dead) { |
if (rest[0] != 0 || !gBundles[id] || gBundles[id]->dead) { |
Line 347 EcpNgDataEvent(int type, void *cookie)
|
Line 352 EcpNgDataEvent(int type, void *cookie)
|
b = gBundles[id]; |
b = gBundles[id]; |
|
|
/* Packet requiring compression */ |
/* Packet requiring compression */ |
if (bundname[0] == 'e') { | if (b1[0] == 'e') { |
bp = EcpDataOutput(b, bp); |
bp = EcpDataOutput(b, bp); |
} else { |
} else { |
/* Packet requiring decompression */ |
/* Packet requiring decompression */ |
Line 505 static void
|
Line 510 static void
|
EcpFailure(Fsm fp, enum fsmfail reason) |
EcpFailure(Fsm fp, enum fsmfail reason) |
{ |
{ |
Bund b = (Bund)fp->arg; |
Bund b = (Bund)fp->arg; |
|
|
|
(void)reason; |
if (Enabled(&b->conf.options, BUND_CONF_CRYPT_REQD)) { |
if (Enabled(&b->conf.options, BUND_CONF_CRYPT_REQD)) { |
FsmFailure(&b->ipcp.fsm, FAIL_CANT_ENCRYPT); |
FsmFailure(&b->ipcp.fsm, FAIL_CANT_ENCRYPT); |
FsmFailure(&b->ipv6cp.fsm, FAIL_CANT_ENCRYPT); |
FsmFailure(&b->ipv6cp.fsm, FAIL_CANT_ENCRYPT); |
Line 516 EcpFailure(Fsm fp, enum fsmfail reason)
|
Line 523 EcpFailure(Fsm fp, enum fsmfail reason)
|
*/ |
*/ |
|
|
int |
int |
EcpStat(Context ctx, int ac, char *av[], void *arg) | EcpStat(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
EcpState const ecp = &ctx->bund->ecp; |
EcpState const ecp = &ctx->bund->ecp; |
|
|
|
(void)ac; |
|
(void)av; |
|
(void)arg; |
|
|
Printf("[%s] %s [%s]\r\n", Pref(&ecp->fsm), Fsm(&ecp->fsm), FsmStateName(ecp->fsm.state)); |
Printf("[%s] %s [%s]\r\n", Pref(&ecp->fsm), Fsm(&ecp->fsm), FsmStateName(ecp->fsm.state)); |
Printf("Enabled protocols:\r\n"); |
Printf("Enabled protocols:\r\n"); |
OptStat(ctx, &ecp->options, gConfList); |
OptStat(ctx, &ecp->options, gConfList); |
Line 607 EcpBuildConfigReq(Fsm fp, u_char *cp)
|
Line 618 EcpBuildConfigReq(Fsm fp, u_char *cp)
|
{ |
{ |
Bund b = (Bund)fp->arg; |
Bund b = (Bund)fp->arg; |
EcpState const ecp = &b->ecp; |
EcpState const ecp = &b->ecp; |
int type; | unsigned type; |
|
|
/* Put in all options that peer hasn't rejected */ |
/* Put in all options that peer hasn't rejected */ |
|
|
Line 827 EcpSubtractBloat(Bund b, int size)
|
Line 838 EcpSubtractBloat(Bund b, int size)
|
*/ |
*/ |
|
|
static int |
static int |
EcpSetCommand(Context ctx, int ac, char *av[], void *arg) | EcpSetCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
EcpState const ecp = &ctx->bund->ecp; |
EcpState const ecp = &ctx->bund->ecp; |
|
|
Line 878 EcpSetCommand(Context ctx, int ac, char *av[], void *a
|
Line 889 EcpSetCommand(Context ctx, int ac, char *av[], void *a
|
static EncType |
static EncType |
EcpFindType(int type, int *indexp) |
EcpFindType(int type, int *indexp) |
{ |
{ |
int k; | unsigned k; |
|
|
for (k = 0; k < ECP_NUM_PROTOS; k++) |
for (k = 0; k < ECP_NUM_PROTOS; k++) |
if (gEncTypes[k]->type == type) |
if (gEncTypes[k]->type == type) |