summaryrefslogtreecommitdiff
path: root/tsip.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2006-11-30 07:29:25 +0000
committerEric S. Raymond <esr@thyrsus.com>2006-11-30 07:29:25 +0000
commit2f6775a8769ed7a2250bb90a68c5fa2617123604 (patch)
treeb0a90a20de3049daf781390419172d628bb83fc0 /tsip.c
parent1c2b3463912566fa8a5841385a56ed1d966138db (diff)
downloadgpsd-2f6775a8769ed7a2250bb90a68c5fa2617123604.tar.gz
Split the packet-sniffer internals out of the session structure.
This is a big, super-intrusive patch but changes no logic at all -- it's all about ripping out some of the gps_device_t structure members into a new gps_packet_t structure. Even the driver API doesn't change at all, this is all libgpsd(3) internals being rearranged. The motivation here is that we want to kill off the ad-hoc Python implementation of a packet-sniffer in gpsfake. To do that we need to be able to write a "pure" packet sniffer that uses the same C code as the daemon's but without being welded to the rest of the libgpsd(3) code. This is the first step towards that.
Diffstat (limited to 'tsip.c')
-rw-r--r--tsip.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/tsip.c b/tsip.c
index 43ac936a..91f84464 100644
--- a/tsip.c
+++ b/tsip.c
@@ -144,32 +144,32 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
unsigned char buf[BUFSIZ];
char buf2[BUFSIZ];
- if (session->packet_type != TSIP_PACKET) {
- gpsd_report(LOG_INF, "tsip_analyze packet type %d\n",session->packet_type);
+ if (session->packet.type != TSIP_PACKET) {
+ gpsd_report(LOG_INF, "tsip_analyze packet type %d\n",session->packet.type);
return 0;
}
/*@ +charint @*/
- if (session->outbuflen < 4 || session->outbuffer[0] != 0x10)
+ if (session->packet.outbuflen < 4 || session->packet.outbuffer[0] != 0x10)
return 0;
/* remove DLE stuffing and put data part of message in buf */
memset(buf, 0, sizeof(buf));
buf2[len = 0] = '\0';
- for (i = 2; i < (int)session->outbuflen; i++) {
- if (session->outbuffer[i] == 0x10)
- if (session->outbuffer[++i] == 0x03)
+ for (i = 2; i < (int)session->packet.outbuflen; i++) {
+ if (session->packet.outbuffer[i] == 0x10)
+ if (session->packet.outbuffer[++i] == 0x03)
break;
(void)snprintf(buf2+strlen(buf2),
sizeof(buf2)-strlen(buf2),
- "%02x", buf[len++] = session->outbuffer[i]);
+ "%02x", buf[len++] = session->packet.outbuffer[i]);
}
/*@ -charint @*/
(void)snprintf(session->gpsdata.tag, sizeof(session->gpsdata.tag),
- "ID%02x", id = (unsigned)session->outbuffer[1]);
+ "ID%02x", id = (unsigned)session->packet.outbuffer[1]);
gpsd_report(LOG_IO, "TSIP packet id 0x%02x length %d: %s\n",id,len,buf2);
(void)time(&now);
@@ -703,14 +703,14 @@ static gps_mask_t tsip_parse_input(struct gps_device_t *session)
{
gps_mask_t st;
- if (session->packet_type == TSIP_PACKET){
+ if (session->packet.type == TSIP_PACKET){
st = tsip_analyze(session);
session->gpsdata.driver_mode = 1; /* binary */
return st;
#ifdef EVERMORE_ENABLE
- } else if (session->packet_type == EVERMORE_PACKET) {
+ } else if (session->packet.type == EVERMORE_PACKET) {
(void)gpsd_switch_driver(session, "EverMore binary");
- st = evermore_parse(session, session->outbuffer, session->outbuflen);
+ st = evermore_parse(session, session->packet.outbuffer, session->packet.outbuflen);
session->gpsdata.driver_mode = 1; /* binary */
return st;
#endif /* EVERMORE_ENABLE */
@@ -730,7 +730,7 @@ struct gps_type_t tsip_binary =
#ifdef ALLOW_RECONFIGURE
.configurator = tsip_configurator,/* initial mode sets */
#endif /* ALLOW_RECONFIGURE */
- .get_packet = packet_get, /* use the generic packet getter */
+ .get_packet = generic_get, /* use the generic packet getter */
.parse_packet = tsip_parse_input, /* parse message packets */
.rtcm_writer = NULL, /* doesn't accept DGPS corrections */
.speed_switcher = tsip_speed_switch,/* change baud rate */