示例#1
0
int main(int argc, char** argv)
{
    printf("Starting... timer\n");

    bsc_schedule_timer(&timer_one, 3, 0);
    bsc_schedule_timer(&timer_two, 5, 0);
    bsc_schedule_timer(&timer_three, 4, 0);

    while (1) {
        bsc_select_main(0);
    }
}
示例#2
0
int rate_ctr_init(void *tall_ctx)
{
	tall_rate_ctr_ctx = tall_ctx;
	rate_ctr_timer.cb = rate_ctr_timer_cb;
	bsc_schedule_timer(&rate_ctr_timer, 1, 0);

	return 0;
}
示例#3
0
static void rate_ctr_timer_cb(void *data)
{
	struct rate_ctr_group *ctrg;

	/* Increment number of ticks before we calculate intervals,
	 * as a counter value of 0 would already wrap all counters */
	timer_ticks++;

	llist_for_each_entry(ctrg, &rate_ctr_groups, list)
		rate_ctr_group_intv(ctrg);

	bsc_schedule_timer(&rate_ctr_timer, 1, 0);
}
示例#4
0
文件: misdn.c 项目: techniker/openBSC
static int handle_ts1_write(struct bsc_fd *bfd)
{
	struct e1inp_line *line = bfd->data;
	unsigned int ts_nr = bfd->priv_nr;
	struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
	struct e1inp_sign_link *sign_link;
	struct sockaddr_mISDN sa;
	struct msgb *msg;
	struct mISDNhead *hh;
	u_int8_t *l2_data;
	int ret;

	bfd->when &= ~BSC_FD_WRITE;

	/* get the next msg for this timeslot */
	msg = e1inp_tx_ts(e1i_ts, &sign_link);
	if (!msg) {
		/* no message after tx delay timer */
		return 0;
	}

	l2_data = msg->data;

	/* prepend the mISDNhead */
	hh = (struct mISDNhead *) msgb_push(msg, sizeof(*hh));
	hh->prim = DL_DATA_REQ;

	DEBUGP(DMI, "TX channel(%d) TEI(%d) SAPI(%d): %s\n",
		sign_link->driver.misdn.channel, sign_link->tei,
		sign_link->sapi, hexdump(l2_data, msg->len - MISDN_HEADER_LEN));

	/* construct the sockaddr */
	sa.family = AF_ISDN;
	sa.sapi = sign_link->sapi;
	sa.dev = sign_link->tei;
	sa.channel = sign_link->driver.misdn.channel;

	ret = sendto(bfd->fd, msg->data, msg->len, 0,
		     (struct sockaddr *)&sa, sizeof(sa));
	if (ret < 0)
		fprintf(stderr, "%s sendto failed %d\n", __func__, ret);
	msgb_free(msg);

	/* set tx delay timer for next event */
	e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
	e1i_ts->sign.tx_timer.data = e1i_ts;
	bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 50000);

	return ret;
}
示例#5
0
static void timer_fired(unsigned long data)
{
    printf("Fired timer: %lu\n", data);

    if (data == 1) {
        bsc_schedule_timer(&timer_one, 3, 0);
        bsc_del_timer(&timer_two);
    } else if (data == 2) {
        printf("Should not be fired... bug in del_timer\n");
    } else if (data == 3) {
        printf("Timer fired not registering again\n");
    } else  {
        printf("wtf... wrong data\n");
    }
}