[OpenWrt-Devel] [PATCH v2 1/3] ar71xx: add kernel support for the EnGenius ESR900
Forest Crossman
cyrozap at gmail.com
Tue Jun 24 10:09:50 EDT 2014
The MAC as it's stored the u-boot environment looks like
'ethaddr="XX:XX:XX:XX:XX:XX"', so to get the other functions to parse
the MAC correctly, I had to get rid of the quotes before and after the
MAC. There might be a better way to do it, but this method didn't seem
too horrible. All this function does is loop through each char in the
string to check if it's a quotation mark. If it is, it skips over it
and puts the next char in the place the quote would go, effectively
doing a `tr -d '\"'` on the MAC string. It then fills the rest of the
output array with null bytes before returning it. If the MAC string
doesn't have any quotes in it, it just returns the input string.
I suppose I could have just checked to make sure the first and last
chars were quotes and then returned the MAC string sans those chars,
but that didn't occur to me at the time I was writing that function.
--
Forest Crossman
On Tue, Jun 24, 2014 at 9:01 AM, John Crispin <john at phrozen.org> wrote:
> Hi,
>
> On 22/06/2014 22:20, Forest Crossman wrote:
>> diff --git a/target/linux/ar71xx/files/arch/mips/ath79/nvram.c
>> b/target/linux/ar71xx/files/arch/mips/ath79/nvram.c index
>> 43911b8..41c3542 100644 ---
>> a/target/linux/ar71xx/files/arch/mips/ath79/nvram.c +++
>> b/target/linux/ar71xx/files/arch/mips/ath79/nvram.c @@ -16,6
>> +16,21 @@
>>
>> #include "nvram.h"
>>
>> +char *ath79_nvram_sanitize_mac(char *input) +{ + int i,j; + char
>> *output=input; + for (i = 0, j = 0; i<strlen(input); i++,j++) + {
>> + if (input[i]!='\"') + output[j]=input[i]; + else + j--; + }
>> + output[j]=0; + return output; +} + char
>> *ath79_nvram_find_var(const char *name, const char *buf, unsigned
>> buf_len) { unsigned len = strlen(name);
>
> this loop is a bit weird. ca you tell us in what way the mac is broken
> on your board ?
>
> John
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list