2014-08-15 23:31:33 +02:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-15 23:31:33 +02:00
|
|
|
libcapwap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-15 23:31:33 +02:00
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-15 23:31:33 +02:00
|
|
|
*/
|
2018-03-03 17:42:28 +01:00
|
|
|
#include "mbag.h"
|
2014-08-15 23:31:33 +02:00
|
|
|
#include <time.h>
|
|
|
|
#include "conn.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
uint8_t * conn_q_get_packet(struct conn * conn)
|
|
|
|
{
|
|
|
|
struct timespec timespec;
|
|
|
|
clock_gettime(CLOCK_REALTIME,×pec);
|
|
|
|
timespec.tv_sec++;
|
|
|
|
|
2014-08-15 23:31:33 +02:00
|
|
|
/* wait one second to get a packet */
|
2014-07-11 22:12:11 +02:00
|
|
|
if (sem_timedwait(&conn->q_sem,×pec)==-1){
|
|
|
|
return NULL;
|
|
|
|
};
|
2014-08-15 23:31:33 +02:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
int qrpos = conn->qrpos+1;
|
|
|
|
if (qrpos==conn->qsize)
|
|
|
|
qrpos=0;
|
|
|
|
conn->qrpos=qrpos;
|
|
|
|
return conn->q[qrpos];
|
|
|
|
}
|