diff options
-rw-r--r-- | drivers.c | 17 | ||||
-rw-r--r-- | gps.h | 2 | ||||
-rw-r--r-- | gpsd.xml | 9 | ||||
-rw-r--r-- | gpsd_json.xml | 14 | ||||
-rw-r--r-- | libgps_json.c | 2 | ||||
-rw-r--r-- | shared_json.c | 2 |
6 files changed, 36 insertions, 10 deletions
@@ -1229,11 +1229,26 @@ static void path_rewrite(struct gps_device_t *session, char *prefix) static gps_mask_t json_pass_packet(struct gps_device_t *session UNUSED) { - /* FIX-ME: only tags the first of multiple devices on remote gpsd */ gpsd_report(LOG_IO, "<= GPS: %s\n", (char *)session->packet.outbuffer); + + /* devices and paths need to be edited to */ if (strstr((char *)session->packet.outbuffer, "DEVICE") != NULL) path_rewrite(session, "\"path\":\""); path_rewrite(session, "\"device\":\""); + + /* mark certain responses without a path or device attribute */ + if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL + || strstr((char *)session->packet.outbuffer, "WATCH") != NULL) { + session->packet.outbuffer[session->packet.outbuflen] = '\0'; + (void)strlcat((char *)session->packet.outbuffer, ",\"remote\":\"", + sizeof(session->packet.outbuffer)); + (void)strlcat((char *)session->packet.outbuffer, + session->gpsdata.dev.path, + sizeof(session->packet.outbuffer)); + (void)strlcat((char *)session->packet.outbuffer, "\"}", + sizeof(session->packet.outbuffer)); + } + gpsd_report (LOG_PROG, "JSON, passing through %s\n", (char *)session->packet.outbuffer); @@ -1539,6 +1539,7 @@ struct version_t { char release[64]; /* external version */ char rev[64]; /* internal revision ID */ int proto_major, proto_minor; /* API major and minor versions */ + char remote[GPS_PATH_MAX]; /* could be from a remote device */ }; struct devconfig_t { @@ -1566,6 +1567,7 @@ struct policy_t { bool timing; /* requesting timing info */ int loglevel; /* requested log level of messages */ char devpath[GPS_PATH_MAX]; /* specific device to watch */ + char remote[GPS_PATH_MAX]; /* ...if this was passthrough */ }; /* @@ -793,15 +793,6 @@ supported.</para> <para>The ISGPS used for RTCM2 and subframes decoder logic is sufficiently convoluted to confuse some compiler optimizers, notably in GCC 3.x at -O2, into generating bad code.</para> - -<para>The code to pass through JSON from slave -<application>gpsd</application> instances rewrites any object -containing a path or device attribute so it is marked as ciming from a -remote; in particular, this marks TPV, SKY, ATT, DEVICE, and DEVICES -reports. VERSION and WATCH reports received from a slave, which do not -contain a path or device attribute, are passed to clients -unaltered. It is up to the application to track which daemon instance -issued them.</para> </refsect1> <refsect1 id='files'><title>FILES</title> diff --git a/gpsd_json.xml b/gpsd_json.xml index c9030881..3d4ad5a8 100644 --- a/gpsd_json.xml +++ b/gpsd_json.xml @@ -845,6 +845,13 @@ will assert ATT_IS.</para> <entry>numeric</entry> <entry>API minor revision level..</entry> </row> +<row> + <entry>remote</entry> + <entry>No</entry> + <entry>string</entry> + <entry>Path to the remote daemon reporting this version. If + empty, this is the version of the local daemon.</entry> +</row> </tbody> </tgroup> </table> @@ -997,6 +1004,13 @@ object.</para> in which device responses aren't tagged. Has no effect when used with enable:false.</entry> </row> +<row> + <entry>remote</entry> + <entry>No</entry> + <entry>string</entry> + <entry>Path to the remote daemon reporting the watch set. If + empty, this is the version of the local daemon.</entry> +</row> </tbody> </tgroup> </table> diff --git a/libgps_json.c b/libgps_json.c index d3bf1956..b53d6da4 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -316,6 +316,8 @@ static int json_version_read(const char *buf, struct gps_data_t *gpsdata, .len = sizeof(gpsdata->version.rev)}, {"proto_major", t_integer, .addr.integer = &gpsdata->version.proto_major}, {"proto_minor", t_integer, .addr.integer = &gpsdata->version.proto_minor}, + {"remote", t_string, .addr.string = gpsdata->version.remote, + .len = sizeof(gpsdata->version.remote)}, {NULL}, /* *INDENT-ON* */ }; diff --git a/shared_json.c b/shared_json.c index 0246833d..766a7492 100644 --- a/shared_json.c +++ b/shared_json.c @@ -98,6 +98,8 @@ int json_watch_read(const char *buf, {"timing", t_boolean, .addr.boolean = &ccp->timing}, {"device", t_string, .addr.string = ccp->devpath, .len = sizeof(ccp->devpath)}, + {"remote", t_string, .addr.string = ccp->remote, + .len = sizeof(ccp->remote)}, {NULL}, }; /* *INDENT-ON* */ |