[PATCH v1 04/25] j1939: rename addr.pgn to addr.dst_pgn

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



we will need local_pgn or src_pgn as well

Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
 net/can/j1939/address-claim.c |  6 +++---
 net/can/j1939/j1939-priv.h    |  2 +-
 net/can/j1939/main.c          | 18 +++++++++---------
 net/can/j1939/socket.c        | 14 +++++++-------
 net/can/j1939/transport.c     | 36 +++++++++++++++++------------------
 5 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/net/can/j1939/address-claim.c b/net/can/j1939/address-claim.c
index 333ed05a60ec..cb3f7a08df23 100644
--- a/net/can/j1939/address-claim.c
+++ b/net/can/j1939/address-claim.c
@@ -35,7 +35,7 @@ static inline bool j1939_ac_msg_is_request(struct sk_buff *skb)
 	struct j1939_sk_buff_cb *skcb = j1939_skb_to_cb(skb);
 	int req_pgn;
 
-	if (skb->len < 3 || skcb->addr.pgn != J1939_PGN_REQUEST)
+	if (skb->len < 3 || skcb->addr.dst_pgn != J1939_PGN_REQUEST)
 		return false;
 
 	req_pgn = skb->data[0] | (skb->data[1] << 8) | (skb->data[2] << 16);
@@ -79,7 +79,7 @@ int j1939_ac_fixup(struct j1939_priv *priv, struct sk_buff *skb)
 	u8 addr;
 
 	/* network mgmt: address claiming msgs */
-	if (skcb->addr.pgn == J1939_PGN_ADDRESS_CLAIMED) {
+	if (skcb->addr.dst_pgn == J1939_PGN_ADDRESS_CLAIMED) {
 		struct j1939_ecu *ecu;
 
 		ret = j1939_ac_verify_outgoing(priv, skb);
@@ -206,7 +206,7 @@ void j1939_ac_recv(struct j1939_priv *priv, struct sk_buff *skb)
 	struct j1939_ecu *ecu;
 
 	/* network mgmt */
-	if (skcb->addr.pgn == J1939_PGN_ADDRESS_CLAIMED) {
+	if (skcb->addr.dst_pgn == J1939_PGN_ADDRESS_CLAIMED) {
 		j1939_ac_process(priv, skb);
 	} else if (j1939_address_is_unicast(skcb->addr.sa)) {
 		/* assign source name */
diff --git a/net/can/j1939/j1939-priv.h b/net/can/j1939/j1939-priv.h
index df058d08fe68..127b4e28b16a 100644
--- a/net/can/j1939/j1939-priv.h
+++ b/net/can/j1939/j1939-priv.h
@@ -113,7 +113,7 @@ struct j1939_ecu *j1939_ecu_get_by_name_locked(struct j1939_priv *priv,
 struct j1939_addr {
 	name_t src_name;
 	name_t dst_name;
-	pgn_t pgn;
+	pgn_t dst_pgn;
 
 	u8 sa;
 	u8 da;
diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index 11b63015b4f0..3b2fb742cb71 100644
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -61,12 +61,12 @@ static void j1939_can_recv(struct sk_buff *iskb, void *data)
 	skcb->insock = iskb->sk;
 	skcb->priority = (cf->can_id >> 26) & 0x7;
 	skcb->addr.sa = cf->can_id;
-	skcb->addr.pgn = (cf->can_id >> 8) & J1939_PGN_MAX;
-	if (j1939_pgn_is_pdu1(skcb->addr.pgn)) {
+	skcb->addr.dst_pgn = (cf->can_id >> 8) & J1939_PGN_MAX;
+	if (j1939_pgn_is_pdu1(skcb->addr.dst_pgn)) {
 		/* Type 1: with destination address */
-		skcb->addr.da = skcb->addr.pgn;
+		skcb->addr.da = skcb->addr.dst_pgn;
 		/* normalize pgn: strip dst address */
-		skcb->addr.pgn &= 0x3ff00;
+		skcb->addr.dst_pgn &= 0x3ff00;
 	} else {
 		/* set broadcast address */
 		skcb->addr.da = J1939_NO_ADDR;
@@ -242,10 +242,10 @@ int j1939_send_one(struct j1939_priv *priv, struct sk_buff *skb)
 	struct can_frame *cf;
 
 	/* apply sanity checks */
-	if (j1939_pgn_is_pdu1(skcb->addr.pgn))
-		skcb->addr.pgn &= 0x3ff00;
+	if (j1939_pgn_is_pdu1(skcb->addr.dst_pgn))
+		skcb->addr.dst_pgn &= 0x3ff00;
 	else
-		skcb->addr.pgn &= J1939_PGN_MAX;
+		skcb->addr.dst_pgn &= J1939_PGN_MAX;
 
 	if (skcb->priority > 7)
 		skcb->priority = 6;
@@ -263,9 +263,9 @@ int j1939_send_one(struct j1939_priv *priv, struct sk_buff *skb)
 
 	canid = CAN_EFF_FLAG |
 		(skcb->priority << 26) |
-		(skcb->addr.pgn << 8) |
+		(skcb->addr.dst_pgn << 8) |
 		skcb->addr.sa;
-	if (j1939_pgn_is_pdu1(skcb->addr.pgn))
+	if (j1939_pgn_is_pdu1(skcb->addr.dst_pgn))
 		canid |= skcb->addr.da << 8;
 
 	cf->can_id = canid;
diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
index b44f21dee3fb..bd4e29d1e0ff 100644
--- a/net/can/j1939/socket.c
+++ b/net/can/j1939/socket.c
@@ -109,7 +109,7 @@ static inline bool j1939_packet_match(const struct j1939_sk_buff_cb *skcb,
 	 * Sockets using dynamic addressing in their filters should not set it.
 	 */
 	for (; nfilter; ++f, --nfilter) {
-		if ((skcb->addr.pgn & f->pgn_mask) != (f->pgn & f->pgn_mask))
+		if ((skcb->addr.dst_pgn & f->pgn_mask) != (f->pgn & f->pgn_mask))
 			continue;
 		if ((skcb->addr.sa & f->addr_mask) != (f->addr & f->addr_mask))
 			continue;
@@ -188,7 +188,7 @@ static int j1939_sk_init(struct sock *sk)
 	jsk->sk.sk_reuse = 1; /* per default */
 	jsk->addr.sa = J1939_NO_ADDR;
 	jsk->addr.da = J1939_NO_ADDR;
-	jsk->addr.pgn = J1939_NO_PGN;
+	jsk->addr.dst_pgn = J1939_NO_PGN;
 	atomic_set(&jsk->skb_pending, 0);
 	return 0;
 }
@@ -261,7 +261,7 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 
 	/* set default transmit pgn */
 	if (j1939_pgn_is_valid(addr->can_addr.j1939.pgn))
-		jsk->addr.pgn = addr->can_addr.j1939.pgn;
+		jsk->addr.dst_pgn = addr->can_addr.j1939.pgn;
 	jsk->addr.src_name = addr->can_addr.j1939.name;
 	jsk->addr.sa = addr->can_addr.j1939.addr;
 
@@ -318,7 +318,7 @@ static int j1939_sk_connect(struct socket *sock, struct sockaddr *uaddr,
 	jsk->addr.da = addr->can_addr.j1939.addr;
 
 	if (j1939_pgn_is_valid(addr->can_addr.j1939.pgn))
-		jsk->addr.pgn = addr->can_addr.j1939.pgn;
+		jsk->addr.dst_pgn = addr->can_addr.j1939.pgn;
 
 	jsk->state |= J1939_SOCK_CONNECTED;
 
@@ -332,7 +332,7 @@ static void j1939_sk_sock2sockaddr_can(struct sockaddr_can *addr,
 {
 	addr->can_family = AF_CAN;
 	addr->can_ifindex = jsk->ifindex;
-	addr->can_addr.j1939.pgn = jsk->addr.pgn;
+	addr->can_addr.j1939.pgn = jsk->addr.dst_pgn;
 	if (peer) {
 		addr->can_addr.j1939.name = jsk->addr.dst_name;
 		addr->can_addr.j1939.addr = jsk->addr.da;
@@ -579,7 +579,7 @@ static int j1939_sk_recvmsg(struct socket *sock, struct msghdr *msg,
 		paddr->can_ifindex = skb->skb_iif;
 		paddr->can_addr.j1939.name = skcb->addr.src_name;
 		paddr->can_addr.j1939.addr = skcb->addr.sa;
-		paddr->can_addr.j1939.pgn = skcb->addr.pgn;
+		paddr->can_addr.j1939.pgn = skcb->addr.dst_pgn;
 	}
 
 	sock_recv_ts_and_drops(msg, sk, skb);
@@ -633,7 +633,7 @@ static struct sk_buff *j1939_sk_alloc_skb(struct net_device *ndev, struct sock *
 			skcb->addr.da = addr->can_addr.j1939.addr;
 		}
 		if (j1939_pgn_is_valid(addr->can_addr.j1939.pgn))
-			skcb->addr.pgn = addr->can_addr.j1939.pgn;
+			skcb->addr.dst_pgn = addr->can_addr.j1939.pgn;
 	}
 
 	*errcode = ret;
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 266ed16ec8c8..b2d7fc9127ab 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -383,14 +383,14 @@ static struct sk_buff *j1939_tp_tx_dat_new(struct j1939_priv *priv,
 
 	if (ctl) {
 		if (extd)
-			skcb->addr.pgn = J1939_ETP_PGN_CTL;
+			skcb->addr.dst_pgn = J1939_ETP_PGN_CTL;
 		else
-			skcb->addr.pgn = J1939_TP_PGN_CTL;
+			skcb->addr.dst_pgn = J1939_TP_PGN_CTL;
 	} else {
 		if (extd)
-			skcb->addr.pgn = J1939_ETP_PGN_DAT;
+			skcb->addr.dst_pgn = J1939_ETP_PGN_DAT;
 		else
-			skcb->addr.pgn = J1939_TP_PGN_DAT;
+			skcb->addr.dst_pgn = J1939_TP_PGN_DAT;
 	}
 
 	return skb;
@@ -444,7 +444,7 @@ static inline int j1939_tp_tx_ctl(struct j1939_session *session,
 
 	return j1939_xtp_do_tx_ctl(priv, &session->skcb, session->extd,
 				   swap_src_dst,
-				   session->skcb.addr.pgn, dat);
+				   session->skcb.addr.dst_pgn, dat);
 }
 
 static int j1939_xtp_tx_abort(struct j1939_priv *priv,
@@ -710,7 +710,7 @@ static void j1939_session_cancel(struct j1939_session *session,
 	if (err && !j1939_cb_is_broadcast(&session->skcb))
 		j1939_xtp_tx_abort(priv, &session->skcb, session->extd,
 				   !(session->skcb.src_flags & J1939_ECU_LOCAL),
-				   err, session->skcb.addr.pgn);
+				   err, session->skcb.addr.dst_pgn);
 
 	__j1939_session_drop(session);
 }
@@ -747,7 +747,7 @@ static void j1939_xtp_rx_bad_message_one(struct j1939_priv *priv,
 	}
 
 	/* FIXME: extend session match to search for PGN? In case of BOM TP.
-	 * (session->skcb.addr.pgn == pgn)
+	 * (session->skcb.addr.dst_pgn == pgn)
 	 */
 	/* do not allow TP control messages on 2 pgn's */
 	j1939_session_cancel(session, J1939_XTP_ABORT_FAULT);
@@ -781,7 +781,7 @@ static void j1939_xtp_rx_abort_one(struct j1939_priv *priv, struct sk_buff *skb,
 		 * do not drop session when a transmit session did not
 		 * start yet
 		 */
-	} else if (session->skcb.addr.pgn == pgn) {
+	} else if (session->skcb.addr.dst_pgn == pgn) {
 		j1939_session_timers_cancel(session);
 		j1939_session_cancel(session, J1939_XTP_ABORT_NO_ERROR);
 	}
@@ -813,7 +813,7 @@ static void j1939_xtp_rx_eoma(struct j1939_session *session, struct sk_buff *skb
 	pgn = j1939_xtp_ctl_to_pgn(skb->data);
 
 	j1939_session_timers_cancel(session);
-	if (session->skcb.addr.pgn != pgn) {
+	if (session->skcb.addr.dst_pgn != pgn) {
 		struct j1939_sk_buff_cb *skcb = j1939_skb_to_cb(skb);
 
 		j1939_xtp_tx_abort(priv, skcb, extd, true, J1939_XTP_ABORT_BUSY,
@@ -836,7 +836,7 @@ static void j1939_xtp_rx_cts(struct j1939_session *session, struct sk_buff *skb,
 	dat = skb->data;
 	pgn = j1939_xtp_ctl_to_pgn(skb->data);
 
-	if (session->skcb.addr.pgn != pgn) {
+	if (session->skcb.addr.dst_pgn != pgn) {
 		struct j1939_sk_buff_cb *skcb = j1939_skb_to_cb(skb);
 		/* what to do? */
 		j1939_xtp_tx_abort(priv, skcb, extd, true, J1939_XTP_ABORT_BUSY,
@@ -939,7 +939,7 @@ static struct j1939_session *j1939_session_fresh_new(struct j1939_priv *priv,
 	skcb = j1939_skb_to_cb(skb);
 	memcpy(skcb, rel_skcb, sizeof(*skcb));
 	j1939_fix_cb(skcb);
-	skcb->addr.pgn = pgn;
+	skcb->addr.dst_pgn = pgn;
 
 	session = j1939_session_new(priv, skb, skb->len);
 	if (!session) {
@@ -1058,7 +1058,7 @@ static int j1939_xtp_rx_rts_current(struct j1939_session *session,
 		j1939_session_timers_cancel(session);
 		j1939_session_cancel(session, J1939_XTP_ABORT_BUSY);
 
-		if (pgn != session->skcb.addr.pgn &&
+		if (pgn != session->skcb.addr.dst_pgn &&
 		    dat[0] != J1939_TP_CMD_BAM)
 			j1939_xtp_tx_abort(priv, skcb, extd, true,
 					   J1939_XTP_ABORT_BUSY, pgn);
@@ -1103,7 +1103,7 @@ static void j1939_xtp_rx_dpo(struct j1939_session *session, struct sk_buff *skb)
 
 	pgn = j1939_xtp_ctl_to_pgn(dat);
 
-	if (session->skcb.addr.pgn != pgn) {
+	if (session->skcb.addr.dst_pgn != pgn) {
 		netdev_info(priv->ndev, "%s: different pgn\n", __func__);
 		j1939_xtp_tx_abort(priv, skcb, true, true, J1939_XTP_ABORT_BUSY,
 				   pgn);
@@ -1238,10 +1238,10 @@ struct j1939_session *j1939_tp_send(struct j1939_priv *priv,
 	bool extd = J1939_REGULAR;
 	int ret;
 
-	if (skcb->addr.pgn == J1939_TP_PGN_DAT ||
-	    skcb->addr.pgn == J1939_TP_PGN_CTL ||
-	    skcb->addr.pgn == J1939_ETP_PGN_DAT ||
-	    skcb->addr.pgn == J1939_ETP_PGN_CTL)
+	if (skcb->addr.dst_pgn == J1939_TP_PGN_DAT ||
+	    skcb->addr.dst_pgn == J1939_TP_PGN_CTL ||
+	    skcb->addr.dst_pgn == J1939_ETP_PGN_DAT ||
+	    skcb->addr.dst_pgn == J1939_ETP_PGN_CTL)
 		/* avoid conflict */
 		return ERR_PTR(-EDOM);
 
@@ -1412,7 +1412,7 @@ int j1939_tp_recv(struct j1939_priv *priv, struct sk_buff *skb)
 	if (!j1939_tp_im_involved_anydir(skcb))
 		return 0;
 
-	switch (skcb->addr.pgn) {
+	switch (skcb->addr.dst_pgn) {
 	case J1939_ETP_PGN_DAT:
 		extd = J1939_EXTENDED;
 	case J1939_TP_PGN_DAT: /* falltrough */
-- 
2.20.1




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux