The online racing simulator
Any Linux gods out there?
(9 posts, started )
#1 - PoVo
Any Linux gods out there?
Hi, anyone out there a Linux god?

I'm having some trouble with a set top box IPTV player.

I want to change the MAC address (not spoof it using ifconfig) and I have finally found a function which the player uses to get the address from the HW.

Here's an example of the function used:
MAC=`/home/default/rdir.cgi MACAddress`

And here's the function itself:

MACAddress)
#return STB MAC Address
fw_printenv ethaddr 2>/dev/null | awk ' { if( index($0,"ethaddr=") ) { p
;;

My question is - how do I modify the function to return a different MAC address? (I want to input my own).
The MACAddress function code appears to be truncated, could you post it again? BTW, ifconfig or ip link will set the device's MAC just fine so I suppose you shouldn't need to change that function...
#3 - PoVo
The problem with changing it with ifconfig is that there is a later compare of current MAC address vs. MAC address from that function or something like that, and it doesn't load up the system.

When I check the MAC via my router - it's changed but on the actual player interface I see the old MAC

Also the function appears to be the same as the one that I've pasted. Not sure what you mean by truncated so.
#4 - heson
Most likely it should be changed to: (substitute XX for your mac.)

MACAddress)
echo XX:XX:XX:XX:XX:XX
;;

or

MACAddress)
echo ethaddr=XX:XX:XX:XX:XX:XX
;;

Added some line breaks to separate the important stuff into lines

1. MACAddress)
2. #return STB MAC Address
3. fw_printenv ethaddr 2>/dev/null |
4. awk ' {
5. if( index($0,"ethaddr=") ) {
6. pMISSINGCODE
7. ;;

I guess 1 and 7 are for a switch statement.
5 matches the occurance of ethaddr=

If the program looks like this, not only is the coder a noob that does not know awk (He should have done awk '/ethaddr=/{pMISSINGCODE) the DRM/access-protection is equally noobstyle.
#5 - heson
Quote from PoVo :Not sure what you mean by truncated so.

"truncate" means "cut short"

The awk line should not en with "p", it should continue like print $0}}', I guess your terminal cuts long likes instead of wrapping them.
#6 - PoVo
Thanks for the help. Here's the un-truncated code:

MACAddress)
#return STB MAC Address
fw_printenv ethaddr 2>/dev/null | awk ' { if( index($0,"ethaddr=") ) { print substr($0,9) } }'
;;

Can you pls post output of "fw_printenv ethaddr" alone?
#8 - heson

switch %0 #probably earlier in the program
... #some omitted lines
MACAddress) #if the "switch" earlier evaluates to MACAddress (until ;;)
#return STB MAC Address #everything following # is a comment
fw_printenv ethaddr #run a function with arguement ethaddr
2>dev/null #send any error codes to /dev/null
| #send the output to the next program
awk #the next program is a awk interpreater
'{ #run every line in the input through this program (until }' )
if( index($0,"ethaddr=") ) #if the string ethaddr= exists on the line
{ print substr($0,9) } #print tthe string that starts on character 9
}' #end of awk program
;; #end of switch-case

"$0" in awk means the full input line.
"index(string, text)" equals to the byte index for the substring test if found in string or 0.
"if (statement) {code}" runs code if statement equals something not 0.

So the program prints the MAC in plain as XX:XX:XX:XX:XX:XX, replace the full line with "echo 'XX:XX:XX:XX:XX:XX'" and you are done.
#9 - PoVo
Thanks for the help guys, I was pretty stupid not checking the output in the first place

Any Linux gods out there?
(9 posts, started )
FGED GREDG RDFGDR GSFDG