Esempio n. 1
0
/* bind for PPP */
static int
pppoe_session_bind_ppp(pppoe_session *_this)
{
	int len;
	npppd_ppp *ppp;
	struct sockaddr_dl sdl;

	ppp = NULL;
	if ((ppp = ppp_create()) == NULL)
		goto fail;

	PPPOE_SESSION_ASSERT(_this->ppp == NULL);

	if (_this->ppp != NULL)
		return -1;

	_this->ppp = ppp;

	ppp->tunnel_type = PPP_TUNNEL_PPPOE;
	ppp->phy_context = _this;
	ppp->send_packet = pppoe_session_ppp_output;
	ppp->phy_close = pppoe_session_close_by_ppp;

	strlcpy(ppp->phy_label, PPPOE_SESSION_LISTENER_LABEL(_this),
	    sizeof(ppp->phy_label));

	memset(&sdl, 0, sizeof(sdl));
	sdl.sdl_len = sizeof(sdl);
	sdl.sdl_family = AF_LINK;
	len = strlen(pppoe_session_listen_ifname(_this));
	memcpy(sdl.sdl_data, pppoe_session_listen_ifname(_this), len);
	sdl.sdl_nlen = len;
	sdl.sdl_alen = ETHER_ADDR_LEN;
	memcpy(sdl.sdl_data + len, _this->ether_addr, ETHER_ADDR_LEN);

	memcpy(&ppp->phy_info.peer_dl, &sdl, sizeof(sdl));

	if (ppp_init(npppd_get_npppd(), ppp) != 0)
		goto fail;
	ppp->has_acf = 0;


	pppoe_session_log(_this, LOG_NOTICE, "logtype=PPPBind ppp=%d", ppp->id);
	ppp_start(ppp);

	return 0;
fail:
	pppoe_session_log(_this, LOG_ERR, "failed binding ppp");

	if (ppp != NULL)
		ppp_destroy(ppp);
	_this->ppp = NULL;

	return 1;
}
Esempio n. 2
0
/* bind() for ppp */
static int
pptp_call_bind_ppp(pptp_call *_this)
{
	npppd_ppp *ppp;

	ppp = NULL;
	if ((ppp = ppp_create()) == NULL)
		goto fail;

	PPTP_CALL_ASSERT(_this->ppp == NULL);

	if (_this->ppp != NULL)
		return -1;

	_this->ppp = ppp;

	ppp->phy_context = _this;
	ppp->tunnel_type = NPPPD_TUNNEL_PPTP;
	ppp->send_packet = pptp_call_ppp_output;
	ppp->phy_close = pptp_call_closed_by_ppp;

	strlcpy(ppp->phy_label, PPTP_CTRL_LISTENER_TUN_NAME(_this->ctrl),
	    sizeof(ppp->phy_label));

	PPTP_CALL_ASSERT(sizeof(ppp->phy_info) >= _this->ctrl->peer.ss_len);
	memcpy(&ppp->phy_info, &_this->ctrl->peer,
	    MIN(sizeof(ppp->phy_info), _this->ctrl->peer.ss_len));

	if (ppp_init(npppd_get_npppd(), ppp) != 0)
		goto fail;

	pptp_call_log(_this, LOG_NOTICE, "logtype=PPPBind ppp=%d", ppp->id);
	ppp_start(ppp);

	return 0;
fail:
	pptp_call_log(_this, LOG_ERR, "failed binding ppp");

	if (ppp != NULL)
		ppp_destroy(ppp);
	_this->ppp = NULL;

	return 1;
}
Esempio n. 3
0
/**
 * Start PPPoE by doing a Discovery. Adjust MSS/MTU for PPPoE
 * packets (8 byte less than normal DIX ethernet).
 * Enter Session state and kick-start PPP (LCP/IPCP).
 *
 * \todo Fix-me: The new MTU/MSS affects all connections (also those
 *       which doesn't use PPPoE framing).
 */
int pppoe_start (void)
{
  if (!cfg.enable || _pktdevclass != PDCLASS_ETHER)
     return (1);

  if (!pppoe_discovery())
     return (0);

#undef  MSS_MAX
#define MSS_MAX (PPPOE_MAX_DATA - TCP_OVERHEAD)
  _mss = min (_mss, MSS_MAX);

  /* If not already clamped by user/pktdrvr, set MTU == 1492
   */
  if (_mtu > PPPOE_MAX_DATA)
      _mtu = PPPOE_MAX_DATA;

  state = StateSession;
  ppp_start (cfg.trace);
  return (1);
}
Esempio n. 4
0
/* bind ppp */
static int
l2tp_call_bind_ppp(l2tp_call *_this, dialin_proxy_info *dpi)
{
	int code, errcode;
	npppd_ppp *ppp;

	code = L2TP_CDN_RCODE_BUSY;
	errcode = 0;
	ppp = NULL;
	if ((ppp = ppp_create()) == NULL)
		goto fail;

	ASSERT(_this->ppp == NULL);

	if (_this->ppp != NULL)
		return -1;

	_this->ppp = ppp;

	ppp->tunnel_type = NPPPD_TUNNEL_L2TP;
	ppp->phy_context = _this;
	ppp->send_packet = l2tp_call_ppp_output;
	ppp->phy_close = l2tp_call_closed_by_ppp;

	strlcpy(ppp->phy_label, L2TP_CTRL_LISTENER_TUN_NAME(_this->ctrl),
	    sizeof(ppp->phy_label));
	L2TP_CALL_ASSERT(sizeof(ppp->phy_info) >= _this->ctrl->peer.ss_len);
	memcpy(&ppp->phy_info, &_this->ctrl->peer,
	    MIN(sizeof(ppp->phy_info), _this->ctrl->peer.ss_len));
	strlcpy(ppp->calling_number, _this->calling_number,
	    sizeof(ppp->calling_number));
	if (ppp_init(npppd_get_npppd(), ppp) != 0) {
		l2tp_call_log(_this, LOG_ERR, "failed binding ppp");
		goto fail;
	}

	l2tp_call_log(_this, LOG_NOTICE, "logtype=PPPBind ppp=%d", ppp->id);
	if (DIALIN_PROXY_IS_REQUESTED(dpi)) {
		if (!L2TP_CTRL_CONF(_this->ctrl)->accept_dialin) {
			l2tp_call_log(_this, LOG_ERR,
			    "'accept_dialin' is 'false' in the setting.");
			code = L2TP_CDN_RCODE_ERROR_CODE;
			errcode = L2TP_ECODE_INVALID_MESSAGE;
			goto fail;
		}

		if (ppp_dialin_proxy_prepare(ppp, dpi) != 0) {
			code = L2TP_CDN_RCODE_TEMP_NOT_AVALIABLE;
			goto fail;
		}
	}
	ppp_start(ppp);

	return 0;
fail:
	if (ppp != NULL)
		ppp_destroy(ppp);
	_this->ppp = NULL;

	l2tp_call_disconnect(_this, code, 0, NULL, NULL, 0);
	return 1;
}