Message ID | 1470127827-6957-1-git-send-email-forrest.shi@linaro.org |
---|---|
State | New |
Headers | show |
one minor question: Is this API mainly for debugging or is there any other use case? Apart from this Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> Regards, Bala On 2 August 2016 at 14:20, <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> > --- > v2: > fix style issue. > > helper/eth.c | 11 +++++++++++ > helper/include/odp/helper/eth.h | 14 ++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/helper/eth.c b/helper/eth.c > index 9a151fa..393e529 100644 > --- a/helper/eth.c > +++ b/helper/eth.c > @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 >
On 08/02/16 18:21, Bala Manoharan wrote: > one minor question: Is this API mainly for debugging or is there any > other use case? Apart from this that is good point. We need code coverage to merge this function. Please add some simple test for helpers tests also. Maxim. > > Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> > > Regards, > Bala > > > On 2 August 2016 at 14:20, <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> >> --- >> v2: >> fix style issue. >> >> helper/eth.c | 11 +++++++++++ >> helper/include/odp/helper/eth.h | 14 ++++++++++++++ >> 2 files changed, 25 insertions(+) >> >> diff --git a/helper/eth.c b/helper/eth.c >> index 9a151fa..393e529 100644 >> --- a/helper/eth.c >> +++ b/helper/eth.c >> @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 >>
Hi Maxim & Bala, It is a reverse function of the odph_eth_addr_parse(...). It could be used by l2fwd-simple, ipsec or other example like l3fwd to avoid duplicate or similar code. thanks, Forrest On 2 August 2016 at 23:50, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > On 08/02/16 18:21, Bala Manoharan wrote: > >> one minor question: Is this API mainly for debugging or is there any >> other use case? Apart from this >> > > that is good point. We need code coverage to merge this function. Please > add > some simple test for helpers tests also. > > Maxim. > > > >> Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> >> >> Regards, >> Bala >> >> >> On 2 August 2016 at 14:20, <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> >>> --- >>> v2: >>> fix style issue. >>> >>> helper/eth.c | 11 +++++++++++ >>> helper/include/odp/helper/eth.h | 14 ++++++++++++++ >>> 2 files changed, 25 insertions(+) >>> >>> diff --git a/helper/eth.c b/helper/eth.c >>> index 9a151fa..393e529 100644 >>> --- a/helper/eth.c >>> +++ b/helper/eth.c >>> @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 >>> >>> >
Hi, this is the coverage report of call the function by l3fwd. thanks, Forrest On 3 August 2016 at 09:57, Forrest Shi <forrest.shi@linaro.org> wrote: > Hi Maxim & Bala, > > It is a reverse function of the odph_eth_addr_parse(...). > > It could be used by l2fwd-simple, ipsec or other example like l3fwd to > avoid duplicate or similar code. > > thanks, > Forrest > > > On 2 August 2016 at 23:50, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > >> On 08/02/16 18:21, Bala Manoharan wrote: >> >>> one minor question: Is this API mainly for debugging or is there any >>> other use case? Apart from this >>> >> >> that is good point. We need code coverage to merge this function. Please >> add >> some simple test for helpers tests also. >> >> Maxim. >> >> >> >>> Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> >>> >>> Regards, >>> Bala >>> >>> >>> On 2 August 2016 at 14:20, <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> >>>> --- >>>> v2: >>>> fix style issue. >>>> >>>> helper/eth.c | 11 +++++++++++ >>>> helper/include/odp/helper/eth.h | 14 ++++++++++++++ >>>> 2 files changed, 25 insertions(+) >>>> >>>> diff --git a/helper/eth.c b/helper/eth.c >>>> index 9a151fa..393e529 100644 >>>> --- a/helper/eth.c >>>> +++ b/helper/eth.c >>>> @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 >>>> >>>> >> >
On 08/03/16 05:05, Forrest Shi wrote: > Hi, > > this is the coverage report of call the function by l3fwd. > > thanks, > Forrest in that case it's ok, we just need new functions called at least from somewhere.. Maxim. > > On 3 August 2016 at 09:57, Forrest Shi <forrest.shi@linaro.org > <mailto:forrest.shi@linaro.org>> wrote: > > Hi Maxim & Bala, > > It is a reverse function of the odph_eth_addr_parse(...). > > It could be used by l2fwd-simple, ipsec or other example like > l3fwd to avoid duplicate or similar code. > > thanks, > Forrest > > > On 2 August 2016 at 23:50, Maxim Uvarov <maxim.uvarov@linaro.org > <mailto:maxim.uvarov@linaro.org>> wrote: > > On 08/02/16 18:21, Bala Manoharan wrote: > > one minor question: Is this API mainly for debugging or is > there any > other use case? Apart from this > > > that is good point. We need code coverage to merge this > function. Please add > some simple test for helpers tests also. > > Maxim. > > > > Reviewed-by: Balasubramanian Manoharan > <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>> > > Regards, > Bala > > > On 2 August 2016 at 14:20, <forrest.shi@linaro.org > <mailto:forrest.shi@linaro.org>> wrote: > > From: Xuelin Shi <forrest.shi@linaro.org > <mailto: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 > <mailto:forrest.shi@linaro.org>> > --- > v2: > fix style issue. > > helper/eth.c | 11 +++++++++++ > helper/include/odp/helper/eth.h | 14 ++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/helper/eth.c b/helper/eth.c > index 9a151fa..393e529 100644 > --- a/helper/eth.c > +++ b/helper/eth.c > @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 > > > >
Hi Maxim, Any other comments, could it be merged or delayed until someone really needs it? Thanks, Forrest > -----Original Message----- > From: Maxim Uvarov [mailto:maxim.uvarov@linaro.org] > Sent: Wednesday, August 03, 2016 15:01 > To: Forrest Shi <forrest.shi@linaro.org>; bala.manoharan@linaro.org > Cc: lng-odp <lng-odp@lists.linaro.org> > Subject: Re: [lng-odp] [PATCH v2] helper/eth: add mac address to string > conversion > > On 08/03/16 05:05, Forrest Shi wrote: > > Hi, > > > > this is the coverage report of call the function by l3fwd. > > > > thanks, > > Forrest > > in that case it's ok, we just need new functions called at least from somewhere.. > > Maxim. > > > > On 3 August 2016 at 09:57, Forrest Shi <forrest.shi@linaro.org > > <mailto:forrest.shi@linaro.org>> wrote: > > > > Hi Maxim & Bala, > > > > It is a reverse function of the odph_eth_addr_parse(...). > > > > It could be used by l2fwd-simple, ipsec or other example like > > l3fwd to avoid duplicate or similar code. > > > > thanks, > > Forrest > > > > > > On 2 August 2016 at 23:50, Maxim Uvarov <maxim.uvarov@linaro.org > > <mailto:maxim.uvarov@linaro.org>> wrote: > > > > On 08/02/16 18:21, Bala Manoharan wrote: > > > > one minor question: Is this API mainly for debugging or is > > there any > > other use case? Apart from this > > > > > > that is good point. We need code coverage to merge this > > function. Please add > > some simple test for helpers tests also. > > > > Maxim. > > > > > > > > Reviewed-by: Balasubramanian Manoharan > > <bala.manoharan@linaro.org > > <mailto:bala.manoharan@linaro.org>> > > > > Regards, > > Bala > > > > > > On 2 August 2016 at 14:20, <forrest.shi@linaro.org > > <mailto:forrest.shi@linaro.org>> wrote: > > > > From: Xuelin Shi <forrest.shi@linaro.org > > <mailto: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 > > <mailto:forrest.shi@linaro.org>> > > --- > > v2: > > fix style issue. > > > > helper/eth.c | 11 +++++++++++ > > helper/include/odp/helper/eth.h | 14 ++++++++++++++ > > 2 files changed, 25 insertions(+) > > > > diff --git a/helper/eth.c b/helper/eth.c > > index 9a151fa..393e529 100644 > > --- a/helper/eth.c > > +++ b/helper/eth.c > > @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 > > > > > > > >
On 08/10/16 13:41, forrest.shi wrote: > Hi Maxim, > > Any other comments, could it be merged or delayed until someone really needs it? > > Thanks, > Forrest I'm waiting to merge it together with l3fwd. Maxim. > >> -----Original Message----- >> From: Maxim Uvarov [mailto:maxim.uvarov@linaro.org] >> Sent: Wednesday, August 03, 2016 15:01 >> To: Forrest Shi <forrest.shi@linaro.org>; bala.manoharan@linaro.org >> Cc: lng-odp <lng-odp@lists.linaro.org> >> Subject: Re: [lng-odp] [PATCH v2] helper/eth: add mac address to string >> conversion >> >> On 08/03/16 05:05, Forrest Shi wrote: >>> Hi, >>> >>> this is the coverage report of call the function by l3fwd. >>> >>> thanks, >>> Forrest >> in that case it's ok, we just need new functions called at least from somewhere.. >> >> Maxim. >>> On 3 August 2016 at 09:57, Forrest Shi <forrest.shi@linaro.org >>> <mailto:forrest.shi@linaro.org>> wrote: >>> >>> Hi Maxim & Bala, >>> >>> It is a reverse function of the odph_eth_addr_parse(...). >>> >>> It could be used by l2fwd-simple, ipsec or other example like >>> l3fwd to avoid duplicate or similar code. >>> >>> thanks, >>> Forrest >>> >>> >>> On 2 August 2016 at 23:50, Maxim Uvarov <maxim.uvarov@linaro.org >>> <mailto:maxim.uvarov@linaro.org>> wrote: >>> >>> On 08/02/16 18:21, Bala Manoharan wrote: >>> >>> one minor question: Is this API mainly for debugging or is >>> there any >>> other use case? Apart from this >>> >>> >>> that is good point. We need code coverage to merge this >>> function. Please add >>> some simple test for helpers tests also. >>> >>> Maxim. >>> >>> >>> >>> Reviewed-by: Balasubramanian Manoharan >>> <bala.manoharan@linaro.org >>> <mailto:bala.manoharan@linaro.org>> >>> >>> Regards, >>> Bala >>> >>> >>> On 2 August 2016 at 14:20, <forrest.shi@linaro.org >>> <mailto:forrest.shi@linaro.org>> wrote: >>> >>> From: Xuelin Shi <forrest.shi@linaro.org >>> <mailto: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 >>> <mailto:forrest.shi@linaro.org>> >>> --- >>> v2: >>> fix style issue. >>> >>> helper/eth.c | 11 +++++++++++ >>> helper/include/odp/helper/eth.h | 14 ++++++++++++++ >>> 2 files changed, 25 insertions(+) >>> >>> diff --git a/helper/eth.c b/helper/eth.c >>> index 9a151fa..393e529 100644 >>> --- a/helper/eth.c >>> +++ b/helper/eth.c >>> @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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 >>> >>> >>> >>> >
diff --git a/helper/eth.c b/helper/eth.c index 9a151fa..393e529 100644 --- a/helper/eth.c +++ b/helper/eth.c @@ -34,3 +34,14 @@ 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..9291774 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 guarantee 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); + +/** * @} */