Rename BAP 'function' to 'port'
authornorly <ny-git@enpas.org>
Sun, 24 Feb 2019 03:35:59 +0000 (04:35 +0100)
committernorly <ny-git@enpas.org>
Sun, 24 Feb 2019 03:35:59 +0000 (04:35 +0100)
This is more generic, thus allowing for interpreting it as 'registers',
and easier to understand when coming from UDP/IP.

vw-bap-frame.c
vw-bap-rx.c
vw-bap-send.c
vw-bap-sniffer.c
vw-bap-tx.c
vw-bap.h

index 41d9e909d3d182d4a1518de30c57d1c343c2a775..1fa353f5228eb6ee5c1aac2826f86be2d8b7b758 100644 (file)
@@ -28,7 +28,7 @@ int vw_bap_frame_is_valid(struct BAP_Frame *bap_frame)
        if ( 0
                || (bap_frame->opcode > 7)
                || (bap_frame->node > 63)
-               || (bap_frame->function > 63)
+               || (bap_frame->port > 63)
                || (bap_frame->len > 4095)
                || (!bap_frame->is_multiframe && bap_frame->len > 6)
                ) {
@@ -66,7 +66,7 @@ void vw_bap_frame_dump(struct BAP_Frame *bap_frame)
        printf("%u. %2i/%-2i .%02i --",
                bap_frame->opcode,
                bap_frame->node,
-               bap_frame->function,
+               bap_frame->port,
                bap_frame->len);
 
        for (i = 0; i < bap_frame->len; i++) {
index 229a55de596fc06a170e791ec3f53bf1c9c0de70..e17dee3f2837f7484f30c111dad80dc0dff6e34f 100644 (file)
@@ -50,7 +50,7 @@ struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame
                        header = (frame->data[2] << 8) | frame->data[3];
                        bap_frame->opcode = (header >> 12) & 0x7;
                        bap_frame->node = (header >> 6) & 0x3F;
-                       bap_frame->function = (header >> 0) & 0x3F;
+                       bap_frame->port = (header >> 0) & 0x3F;
 
                        bap_frame->len = ((frame->data[0] & 0xF) << 8) | frame->data[1];
 
@@ -126,7 +126,7 @@ struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame
                header = (frame->data[0] << 8) | frame->data[1];
                bap_frame->opcode = (header >> 12) & 0x7;
                bap_frame->node = (header >> 6) & 0x3F;
-               bap_frame->function = (header >> 0) & 0x3F;
+               bap_frame->port = (header >> 0) & 0x3F;
 
                this_len = frame->can_dlc - 2;
 
index 04f91186eee0354c01f4bea6566a09d72895aa1a..55cd22259981ff45329ee9b1e93f96427b5dc32f 100644 (file)
@@ -99,10 +99,10 @@ int main(int argc, char **argv)
        unsigned bap_multiframe;
        unsigned bap_opcode;
        unsigned bap_node;
-       unsigned bap_function;
+       unsigned bap_port;
 
        if (argc < 8) {
-               printf("syntax: %s IFNAME CAN_ID multiframe bap_opcode bap_node bap_function bap_data\n", argv[0]);
+               printf("syntax: %s IFNAME CAN_ID multiframe bap_opcode bap_node bap_port bap_data\n", argv[0]);
                return 1;
        }
 
@@ -111,7 +111,7 @@ int main(int argc, char **argv)
        bap_multiframe = strtoul(argv[3], NULL, 0);
        bap_opcode = strtoul(argv[4], NULL, 0);
        bap_node = strtoul(argv[5], NULL, 0);
-       bap_function = strtoul(argv[6], NULL, 0);
+       bap_port = strtoul(argv[6], NULL, 0);
        /* bap_data */
 
 
@@ -133,7 +133,7 @@ int main(int argc, char **argv)
        bap_frame->is_multiframe = !(!bap_multiframe);
        bap_frame->opcode = bap_opcode & 0x7;
        bap_frame->node = bap_node & 0x3f;
-       bap_frame->function = bap_function & 0x3f;
+       bap_frame->port = bap_port & 0x3f;
        bap_frame->len = 0;
 
        /* Fill payload */
index ac1ef799f146c920e00658100fad2780a977122c..f7f493c548fee8199decf4a8ffd9924a95c8c52e 100644 (file)
@@ -128,12 +128,12 @@ int main(int argc, char **argv)
 
                                bap_frame = vw_bap_handle_can_frame(bap, &frame);
                                if (bap_frame && bap_frame->node == node_id) {
-                                       mvprintw(bap_frame->function, 0, "");
+                                       mvprintw(bap_frame->port, 0, "");
 
                                        printw("%u. %2i/%-2i .%c%02i --",
                                                bap_frame->opcode,
                                                bap_frame->node,
-                                               bap_frame->function,
+                                               bap_frame->port,
                                                bap_frame->is_multiframe ? 'm' : 's',
                                                bap_frame->len);
 
@@ -153,7 +153,7 @@ int main(int argc, char **argv)
                                        printw("\n");
 
                                        /* ASCII dump */
-                                       mvprintw(bap_frame->function, 64, "");
+                                       mvprintw(bap_frame->port, 64, "");
                                        for (i = 0; i < bap_frame->len; i++) {
                                                unsigned char c = bap_frame->data[i];
                                                if (!isprint(c) || c == '\n' || c == '\r') {
index f8a88b77a4aebb94e8a8588e8d45b428f195f68f..a2f5f02709a1bf6e995b22e7a6680bb49a3b48b8 100644 (file)
@@ -18,7 +18,7 @@ static void vw_bap_txer_build_only_can_frame(struct BAP_Frame *bap_frame, struct
        frame->data[0]  = (bap_frame->opcode & 0x7) << 4;
        frame->data[0] |= (bap_frame->node & 0x3f) >> 2;
        frame->data[1]  = (bap_frame->node & 0x3) << 6;
-       frame->data[1] |=  bap_frame->function & 0x3f;
+       frame->data[1] |=  bap_frame->port & 0x3f;
 
        frame->can_dlc = 2 + bap_frame->len;
        memcpy(&frame->data[2], bap_frame->data, bap_frame->len);
@@ -40,7 +40,7 @@ static void vw_bap_txer_build_first_can_frame(struct BAP_TXer* bap, unsigned slo
        frame->data[2]  = (bap_frame->opcode & 0x7) << 4;
        frame->data[2] |= (bap_frame->node & 0x3f) >> 2;
        frame->data[3]  = (bap_frame->node & 0x3) << 6;
-       frame->data[3] |=  bap_frame->function & 0x3f;
+       frame->data[3] |=  bap_frame->port & 0x3f;
 
        if (bap_frame->len <= 4) {
                frame->can_dlc = 4 + bap_frame->len;
index 87a2fc38a7a57c1086cc293aa7dd5fb0b12fa34e..4e6d124fd6e552846e9641be6aef31fe8d017e14 100644 (file)
--- a/vw-bap.h
+++ b/vw-bap.h
@@ -6,7 +6,7 @@
 
 typedef unsigned char BAP_OpCode;
 typedef unsigned char BAP_Node;
-typedef unsigned char BAP_Function;
+typedef unsigned char BAP_Port;
 typedef unsigned short BAP_FrameLen;
 
 
@@ -32,11 +32,11 @@ struct BAP_Frame {
         */
        BAP_Node node;
 
-       /* The "RPC" function, or "status register" ID.
+       /* The "RPC" port, or "status register" ID.
         *
-        * BAP's equivalent of a "TCP port".
+        * BAP's equivalent of a "UDP port".
         */
-       BAP_Function function;
+       BAP_Port port;
 
        /* Payload length, up to 2^12-1 = 4095 bytes. */
        BAP_FrameLen len;