diff mbox

[1/2] helper/eth: add mac address to string conversion

Message ID 1469675708-28540-1-git-send-email-forrest.shi@linaro.org
State Superseded
Headers show

Commit Message

Forrest Shi July 28, 2016, 3:15 a.m. UTC
From: Xuelin Shi <forrest.shi@linaro.org>


generate mac string representation (XX:XX:XX:XX:XX:XX) of odph_ethaddr_t

Signed-off-by: Xuelin Shi <forrest.shi@linaro.org>

---
 helper/eth.c                    | 10 ++++++++++
 helper/include/odp/helper/eth.h | 14 ++++++++++++++
 2 files changed, 24 insertions(+)

-- 
2.1.0.27.g96db324

Comments

Mike Holmes July 28, 2016, 10:25 a.m. UTC | #1
check-odp gave me the following, do you have codespell installed ?
 checkpatch will flag spelling issues for you then.

Using patch:
lng-odp_PATCH_1-2_helper-eth_add_mac_address_to_string_conversion.mbox
Trying to apply patch Patch applied WARNING: 'gurantee' may be misspelled -
perhaps 'guarantee'? #43: FILE: helper/include/odp/helper/eth.h:126: + *
buffer specified by the second param, caller should gurantee the size of
the WARNING: please, no space before tabs #49: FILE:
helper/include/odp/helper/eth.h:132: + * @return ^IPointer to the supplied
buffer$






On 27 July 2016 at 23:15, <forrest.shi@linaro.org> wrote:

> From: Xuelin Shi <forrest.shi@linaro.org>

>

> generate mac string representation (XX:XX:XX:XX:XX:XX) of odph_ethaddr_t

>

> Signed-off-by: Xuelin Shi <forrest.shi@linaro.org>

> ---

>  helper/eth.c                    | 10 ++++++++++

>  helper/include/odp/helper/eth.h | 14 ++++++++++++++

>  2 files changed, 24 insertions(+)

>

> diff --git a/helper/eth.c b/helper/eth.c

> index 9a151fa..1dbe60e 100644

> --- a/helper/eth.c

> +++ b/helper/eth.c

> @@ -34,3 +34,13 @@ int odph_eth_addr_parse(odph_ethaddr_t *mac, const char

> *str)

>

>         return 0;

>  }

> +

> +char *odph_eth_addr_string(odph_ethaddr_t *mac, char *buf)

> +{

> +       uint8_t *byte;

> +

> +       byte = mac->addr;

> +       sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",

> +               byte[0], byte[1], byte[2], byte[3], byte[4], byte[5]);

> +       return buf;

> +}

> diff --git a/helper/include/odp/helper/eth.h

> b/helper/include/odp/helper/eth.h

> index 9f47ddf..fb2b24f 100644

> --- a/helper/include/odp/helper/eth.h

> +++ b/helper/include/odp/helper/eth.h

> @@ -120,6 +120,20 @@ ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) ==

> ODPH_VLANHDR_LEN,

>  int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str);

>

>  /**

> + * Generate text string representation of a MAC address

> + *

> + * The mac address string representation (xx:xx:xx:xx:xx:xx) is stored

> into a

> + * buffer specified by the second param, caller should gurantee the size

> of the

> + * buffer is big enough.

> + *

> + * @param mac   Pointer to MAC address

> + * @param buf   Pointer to buffer to store string

> + *

> + * @return     Pointer to the supplied buffer

> + */

> +char *odph_eth_addr_string(odph_ethaddr_t *mac, char *buf);

> +

> +/**

>   * @}

>   */

>

> --

> 2.1.0.27.g96db324

>

>



-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
diff mbox

Patch

diff --git a/helper/eth.c b/helper/eth.c
index 9a151fa..1dbe60e 100644
--- a/helper/eth.c
+++ b/helper/eth.c
@@ -34,3 +34,13 @@  int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str)
 
 	return 0;
 }
+
+char *odph_eth_addr_string(odph_ethaddr_t *mac, char *buf)
+{
+	uint8_t *byte;
+
+	byte = mac->addr;
+	sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+		byte[0], byte[1], byte[2], byte[3], byte[4], byte[5]);
+	return buf;
+}
diff --git a/helper/include/odp/helper/eth.h b/helper/include/odp/helper/eth.h
index 9f47ddf..fb2b24f 100644
--- a/helper/include/odp/helper/eth.h
+++ b/helper/include/odp/helper/eth.h
@@ -120,6 +120,20 @@  ODP_STATIC_ASSERT(sizeof(odph_vlanhdr_t) == ODPH_VLANHDR_LEN,
 int odph_eth_addr_parse(odph_ethaddr_t *mac, const char *str);
 
 /**
+ * Generate text string representation of a MAC address
+ *
+ * The mac address string representation (xx:xx:xx:xx:xx:xx) is stored into a
+ * buffer specified by the second param, caller should gurantee the size of the
+ * buffer is big enough.
+ *
+ * @param mac   Pointer to MAC address
+ * @param buf   Pointer to buffer to store string
+ *
+ * @return 	Pointer to the supplied buffer
+ */
+char *odph_eth_addr_string(odph_ethaddr_t *mac, char *buf);
+
+/**
  * @}
  */