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

int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
9
	int e = 0; /* error var, to check errors in msg handling */
10 11

	if (ppi->is_new_state)
12
		st_com_restart_annrec_timer(ppi);
13

14 15
	if (st_com_check_record_update(ppi))
		goto state_updated;
16

17 18 19
	switch (ppi->msg_tmp_header.messageType) {

	case PPM_ANNOUNCE:
20
		e = st_com_master_handle_announce(ppi, pkt, plen);
21 22 23 24 25
		break;

	default:
		/* disreguard, nothing to do */
		break;
26
	}
27

28 29 30 31
	if (e == 0)
		st_com_execute_slave(ppi);
	else
		ppi->next_state = PPS_FAULTY;
32

33
state_updated:
34
	/* Leaving this state */
35
	if (ppi->next_state != ppi->state)
36
		pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
37

38
	ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
39

40 41
	return 0;
}