state-passive.c 1.08 KB
Newer Older
1 2 3
/*
 * FIXME: header
 */
4
#include <pptp/pptp.h>
5
#include "common-fun.h"
6 7 8

int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
9
	TimeInternal time; /* TODO: handle it, see handle(...) in protocol.c */
10
	int e = 0; /* error var, to check errors in msg handling */
11

12 13
	if (ppi->is_new_state) {
		pp_timer_start(1 << DSPOR(ppi)->logMinPdelayReqInterval,
14
			ppi->timers[PP_TIMER_PDELAYREQ]);
15 16 17 18 19 20 21

		st_com_restart_annrec_timer(ppi);
	}

	if (st_com_check_record_update(ppi))
		goto state_updated;

22
	switch (ppi->msg_tmp_header.messageType) {
23 24

	case PPM_ANNOUNCE:
25
		e = st_com_master_handle_announce(ppi, pkt, plen);
26 27
		break;

28
	case PPM_PDELAY_REQ:
29
		e = st_com_handle_pdelay_req(ppi, pkt, plen, &time);
30 31 32 33 34 35
		break;

	default:
		/* disreguard, nothing to do */
		break;

36 37
	}

38 39 40 41 42
	if (e == 0)
		st_com_execute_slave(ppi);
	else
		ppi->next_state = PPS_FAULTY;

43 44 45 46

state_updated:
	/* Leaving this state */
	if (ppi->next_state != ppi->state) {
47 48
		pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
		pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]);
49 50
	}

51
	ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
52

53 54
	return 0;
}