version 1.1.1.2, 2016/11/01 09:56:12
|
version 1.1.1.3, 2021/03/17 00:39:23
|
Line 379 static const struct l2tp_msg_info ppp_l2tp_msg_info[]
|
Line 379 static const struct l2tp_msg_info ppp_l2tp_msg_info[]
|
{ SS_ESTABLISHED, SS_DYING, -1 }, |
{ SS_ESTABLISHED, SS_DYING, -1 }, |
{ ORIG_LOCAL, ORIG_REMOTE, -1 }, { SIDE_LAC, -1 }, |
{ ORIG_LOCAL, ORIG_REMOTE, -1 }, { SIDE_LAC, -1 }, |
{ AVP_ACCM, -1 } }, |
{ AVP_ACCM, -1 } }, |
{ NULL } | { NULL, 0, NULL, NULL, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0 }, { 0, 0 } } |
}; |
}; |
|
|
/* Descriptors for each AVP */ |
/* Descriptors for each AVP */ |
Line 431 static const struct ppp_l2tp_avp_info ppp_l2tp_avp_inf
|
Line 431 static const struct ppp_l2tp_avp_info ppp_l2tp_avp_inf
|
}; |
}; |
|
|
/* All control connections */ |
/* All control connections */ |
struct ghash *ppp_l2tp_ctrls; | static struct ghash *ppp_l2tp_ctrls; |
|
|
static uint32_t gNextSerial = 0; |
static uint32_t gNextSerial = 0; |
|
|
Line 451 ppp_l2tp_ctrl_create(struct pevent_ctx *ctx, pthread_m
|
Line 451 ppp_l2tp_ctrl_create(struct pevent_ctx *ctx, pthread_m
|
{ |
{ |
struct ppp_l2tp_ctrl *ctrl; |
struct ppp_l2tp_ctrl *ctrl; |
struct ngm_mkpeer mkpeer; |
struct ngm_mkpeer mkpeer; |
|
unsigned i; |
u_int16_t value16; |
u_int16_t value16; |
int index, i; | int index; |
|
|
/* Init Call Serial Number */ |
/* Init Call Serial Number */ |
if (gNextSerial == 0) |
if (gNextSerial == 0) |
Line 558 ppp_l2tp_ctrl_create(struct pevent_ctx *ctx, pthread_m
|
Line 559 ppp_l2tp_ctrl_create(struct pevent_ctx *ctx, pthread_m
|
0, AVP_HOST_NAME, ctrl->self_name, strlen(ctrl->self_name)) == -1) |
0, AVP_HOST_NAME, ctrl->self_name, strlen(ctrl->self_name)) == -1) |
goto fail; |
goto fail; |
} else { |
} else { |
int len = ctrl->avps->avps[index].vlen; | unsigned len = ctrl->avps->avps[index].vlen; |
if (len >= sizeof(ctrl->self_name)) |
if (len >= sizeof(ctrl->self_name)) |
len = sizeof(ctrl->self_name) - 1; |
len = sizeof(ctrl->self_name) - 1; |
memcpy(ctrl->self_name, ctrl->avps->avps[index].value, len); |
memcpy(ctrl->self_name, ctrl->avps->avps[index].value, len); |
Line 666 ppp_l2tp_initiate(struct ppp_l2tp_ctrl *ctrl, int out,
|
Line 667 ppp_l2tp_initiate(struct ppp_l2tp_ctrl *ctrl, int out,
|
{ |
{ |
struct ppp_l2tp_sess *sess; |
struct ppp_l2tp_sess *sess; |
u_int32_t value32; |
u_int32_t value32; |
int i; | unsigned i; |
|
|
/* Debugging */ |
/* Debugging */ |
Log(LOG_DEBUG, ("L2TP: %s invoked, ctrl=%p out=%d", __FUNCTION__, ctrl, out)); |
Log(LOG_DEBUG, ("L2TP: %s invoked, ctrl=%p out=%d", __FUNCTION__, ctrl, out)); |
Line 773 ppp_l2tp_connected(struct ppp_l2tp_sess *sess,
|
Line 774 ppp_l2tp_connected(struct ppp_l2tp_sess *sess,
|
{ |
{ |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
u_int32_t value32; |
u_int32_t value32; |
int i; | unsigned i; |
|
|
/* Debugging */ |
/* Debugging */ |
Log(LOG_DEBUG, ("L2TP: %s invoked, sess=%p", __FUNCTION__, sess)); |
Log(LOG_DEBUG, ("L2TP: %s invoked, sess=%p", __FUNCTION__, sess)); |
Line 1750 ppp_l2tp_data_event(void *arg)
|
Line 1751 ppp_l2tp_data_event(void *arg)
|
u_int16_t msgtype; |
u_int16_t msgtype; |
char ebuf[64]; |
char ebuf[64]; |
int len; |
int len; |
int i; | unsigned i, j; |
int j; | |
|
|
/* Restart idle timer */ |
/* Restart idle timer */ |
pevent_unregister(&ctrl->idle_timer); |
pevent_unregister(&ctrl->idle_timer); |
Line 1859 ppp_l2tp_data_event(void *arg)
|
Line 1859 ppp_l2tp_data_event(void *arg)
|
|
|
/* Check for valid control connection state */ |
/* Check for valid control connection state */ |
for (i = 0; msg_info->valid_states[i] != -1 |
for (i = 0; msg_info->valid_states[i] != -1 |
&& msg_info->valid_states[i] != ctrl->state; i++); | && msg_info->valid_states[i] != (int)ctrl->state; i++); |
if (msg_info->valid_states[i] == -1) { |
if (msg_info->valid_states[i] == -1) { |
|
|
/* Could be in CS_DYING if we just closed the tunnel */ |
/* Could be in CS_DYING if we just closed the tunnel */ |
Line 1918 ppp_l2tp_data_event(void *arg)
|
Line 1918 ppp_l2tp_data_event(void *arg)
|
|
|
/* Check for valid session state, origination, and side */ |
/* Check for valid session state, origination, and side */ |
for (i = 0; msg_info->valid_states[i] != -1 |
for (i = 0; msg_info->valid_states[i] != -1 |
&& msg_info->valid_states[i] != sess->state; i++); | && msg_info->valid_states[i] != (int)sess->state; i++); |
if (msg_info->valid_states[i] == -1) { |
if (msg_info->valid_states[i] == -1) { |
snprintf(ebuf, sizeof(ebuf), "rec'd %s in state %s", |
snprintf(ebuf, sizeof(ebuf), "rec'd %s in state %s", |
msg_info->name, ppp_l2tp_sess_state_str(sess->state)); |
msg_info->name, ppp_l2tp_sess_state_str(sess->state)); |
Line 1927 ppp_l2tp_data_event(void *arg)
|
Line 1927 ppp_l2tp_data_event(void *arg)
|
goto done; |
goto done; |
} |
} |
for (i = 0; msg_info->valid_orig[i] != -1 |
for (i = 0; msg_info->valid_orig[i] != -1 |
&& msg_info->valid_orig[i] != sess->orig; i++); | && msg_info->valid_orig[i] != (int)sess->orig; i++); |
if (msg_info->valid_orig[i] == -1) { |
if (msg_info->valid_orig[i] == -1) { |
snprintf(ebuf, sizeof(ebuf), "rec'd %s in state %s," |
snprintf(ebuf, sizeof(ebuf), "rec'd %s in state %s," |
" but session originated %sly", msg_info->name, |
" but session originated %sly", msg_info->name, |
Line 1938 ppp_l2tp_data_event(void *arg)
|
Line 1938 ppp_l2tp_data_event(void *arg)
|
goto done; |
goto done; |
} |
} |
for (i = 0; msg_info->valid_side[i] != -1 |
for (i = 0; msg_info->valid_side[i] != -1 |
&& msg_info->valid_side[i] != sess->side; i++); | && msg_info->valid_side[i] != (int)sess->side; i++); |
if (msg_info->valid_side[i] == -1) { |
if (msg_info->valid_side[i] == -1) { |
snprintf(ebuf, sizeof(ebuf), "rec'd %s in state %s," |
snprintf(ebuf, sizeof(ebuf), "rec'd %s in state %s," |
" but we are %s for this session", msg_info->name, |
" but we are %s for this session", msg_info->name, |
Line 2033 ppp_l2tp_handle_SCCRQ(struct ppp_l2tp_ctrl *ctrl,
|
Line 2033 ppp_l2tp_handle_SCCRQ(struct ppp_l2tp_ctrl *ctrl,
|
const u_char *tiebreaker; |
const u_char *tiebreaker; |
struct ghash_walk walk; |
struct ghash_walk walk; |
int diff; |
int diff; |
int i; | unsigned i; |
|
|
|
(void)avps; |
/* See if there is an outstanding SCCRQ to this peer */ |
/* See if there is an outstanding SCCRQ to this peer */ |
ghash_walk_init(ppp_l2tp_ctrls, &walk); |
ghash_walk_init(ppp_l2tp_ctrls, &walk); |
while ((ctrl2 = ghash_walk_next(ppp_l2tp_ctrls, &walk)) != NULL) { |
while ((ctrl2 = ghash_walk_next(ppp_l2tp_ctrls, &walk)) != NULL) { |
Line 2096 static int
|
Line 2097 static int
|
ppp_l2tp_handle_SCCRP(struct ppp_l2tp_ctrl *ctrl, |
ppp_l2tp_handle_SCCRP(struct ppp_l2tp_ctrl *ctrl, |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
{ |
{ |
|
(void)avps; |
/* Do control connection setup */ |
/* Do control connection setup */ |
if (ppp_l2tp_ctrl_setup_1(ctrl, ptrs) == -1) |
if (ppp_l2tp_ctrl_setup_1(ctrl, ptrs) == -1) |
return (-1); |
return (-1); |
Line 2114 static int
|
Line 2116 static int
|
ppp_l2tp_handle_SCCCN(struct ppp_l2tp_ctrl *ctrl, |
ppp_l2tp_handle_SCCCN(struct ppp_l2tp_ctrl *ctrl, |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
{ |
{ |
|
(void)avps; |
/* Do control connection setup */ |
/* Do control connection setup */ |
if (ppp_l2tp_ctrl_setup_2(ctrl, ptrs) == -1) |
if (ppp_l2tp_ctrl_setup_2(ctrl, ptrs) == -1) |
return (-1); |
return (-1); |
Line 2132 ppp_l2tp_handle_StopCCN(struct ppp_l2tp_ctrl *ctrl,
|
Line 2135 ppp_l2tp_handle_StopCCN(struct ppp_l2tp_ctrl *ctrl,
|
struct ppp_l2tp_sess *sess; |
struct ppp_l2tp_sess *sess; |
struct ghash_walk walk; |
struct ghash_walk walk; |
|
|
|
(void)avps; |
/* StopCCN implies closing all sessions */ |
/* StopCCN implies closing all sessions */ |
ctrl->peer_notified = 1; |
ctrl->peer_notified = 1; |
ghash_walk_init(ctrl->sessions, &walk); |
ghash_walk_init(ctrl->sessions, &walk); |
Line 2148 static int
|
Line 2152 static int
|
ppp_l2tp_handle_HELLO(struct ppp_l2tp_ctrl *ctrl, |
ppp_l2tp_handle_HELLO(struct ppp_l2tp_ctrl *ctrl, |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
{ |
{ |
|
(void)avps; |
|
(void)ctrl; |
|
(void)ptrs; |
return (0); |
return (0); |
} |
} |
|
|
Line 2204 static int
|
Line 2211 static int
|
ppp_l2tp_handle_OCRP(struct ppp_l2tp_sess *sess, |
ppp_l2tp_handle_OCRP(struct ppp_l2tp_sess *sess, |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
{ |
{ |
|
(void)avps; |
if (sess->state == SS_DYING) |
if (sess->state == SS_DYING) |
return (0); |
return (0); |
|
|
Line 2240 ppp_l2tp_handle_ICRP(struct ppp_l2tp_sess *sess,
|
Line 2248 ppp_l2tp_handle_ICRP(struct ppp_l2tp_sess *sess,
|
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
char buf[64]; |
char buf[64]; |
|
|
|
(void)avps; |
if (sess->state == SS_DYING) |
if (sess->state == SS_DYING) |
return (0); |
return (0); |
|
|
Line 2268 static int
|
Line 2277 static int
|
ppp_l2tp_handle_CDN(struct ppp_l2tp_sess *sess, |
ppp_l2tp_handle_CDN(struct ppp_l2tp_sess *sess, |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
const struct ppp_l2tp_avp_list *avps, struct ppp_l2tp_avp_ptrs *ptrs) |
{ |
{ |
|
(void)avps; |
sess->peer_notified = 1; |
sess->peer_notified = 1; |
ppp_l2tp_sess_close(sess, ptrs->errresultcode->result, |
ppp_l2tp_sess_close(sess, ptrs->errresultcode->result, |
ptrs->errresultcode->error, ptrs->errresultcode->errmsg); |
ptrs->errresultcode->error, ptrs->errresultcode->errmsg); |
Line 2280 ppp_l2tp_handle_SLI(struct ppp_l2tp_sess *sess,
|
Line 2290 ppp_l2tp_handle_SLI(struct ppp_l2tp_sess *sess,
|
{ |
{ |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
|
|
|
(void)avps; |
if (sess->state == SS_DYING) |
if (sess->state == SS_DYING) |
return (0); |
return (0); |
|
|
Line 2295 ppp_l2tp_handle_WEN(struct ppp_l2tp_sess *sess,
|
Line 2306 ppp_l2tp_handle_WEN(struct ppp_l2tp_sess *sess,
|
{ |
{ |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
struct ppp_l2tp_ctrl *const ctrl = sess->ctrl; |
|
|
|
(void)avps; |
if (sess->state == SS_DYING) |
if (sess->state == SS_DYING) |
return (0); |
return (0); |
|
|
Line 2482 ppp_l2tp_ctrl_equal(struct ghash *g, const void *item1
|
Line 2494 ppp_l2tp_ctrl_equal(struct ghash *g, const void *item1
|
const struct ppp_l2tp_ctrl *const ctrl1 = item1; |
const struct ppp_l2tp_ctrl *const ctrl1 = item1; |
const struct ppp_l2tp_ctrl *const ctrl2 = item2; |
const struct ppp_l2tp_ctrl *const ctrl2 = item2; |
|
|
|
(void)g; |
return (ctrl1->config.tunnel_id == ctrl2->config.tunnel_id); |
return (ctrl1->config.tunnel_id == ctrl2->config.tunnel_id); |
} |
} |
|
|
Line 2490 ppp_l2tp_ctrl_hash(struct ghash *g, const void *item)
|
Line 2503 ppp_l2tp_ctrl_hash(struct ghash *g, const void *item)
|
{ |
{ |
const struct ppp_l2tp_ctrl *const ctrl = item; |
const struct ppp_l2tp_ctrl *const ctrl = item; |
|
|
|
(void)g; |
return ((u_int32_t)ctrl->config.tunnel_id); |
return ((u_int32_t)ctrl->config.tunnel_id); |
} |
} |
|
|
Line 2499 ppp_l2tp_sess_equal(struct ghash *g, const void *item1
|
Line 2513 ppp_l2tp_sess_equal(struct ghash *g, const void *item1
|
const struct ppp_l2tp_sess *const sess1 = item1; |
const struct ppp_l2tp_sess *const sess1 = item1; |
const struct ppp_l2tp_sess *const sess2 = item2; |
const struct ppp_l2tp_sess *const sess2 = item2; |
|
|
|
(void)g; |
return (sess1->config.session_id == sess2->config.session_id); |
return (sess1->config.session_id == sess2->config.session_id); |
} |
} |
|
|
Line 2507 ppp_l2tp_sess_hash(struct ghash *g, const void *item)
|
Line 2522 ppp_l2tp_sess_hash(struct ghash *g, const void *item)
|
{ |
{ |
const struct ppp_l2tp_sess *const sess = item; |
const struct ppp_l2tp_sess *const sess = item; |
|
|
|
(void)g; |
return ((u_int32_t)sess->config.session_id); |
return ((u_int32_t)sess->config.session_id); |
} |
} |
|
|
Line 2523 ppp_l2tp_ctrl_dump(struct ppp_l2tp_ctrl *ctrl,
|
Line 2539 ppp_l2tp_ctrl_dump(struct ppp_l2tp_ctrl *ctrl,
|
{ |
{ |
char buf[1024]; |
char buf[1024]; |
va_list args; |
va_list args; |
int i; | unsigned i; |
| |
| (void)ctrl; |
| |
| if ((gLogOptions & LOG_DEBUG) == 0) |
| return; |
|
|
va_start(args, fmt); |
va_start(args, fmt); |
vsnprintf(buf, sizeof(buf), fmt, args); |
vsnprintf(buf, sizeof(buf), fmt, args); |