Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
29
Issues
29
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
4e384293
Commit
4e384293
authored
Jul 04, 2012
by
Wesley W. Terpstra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add controls to get/set the MAC+IP in onewire EEPROM or runtime
Tidy up printing at startup
parent
196cba51
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
8 deletions
+73
-8
endpoint.c
dev/endpoint.c
+2
-2
endpoint.h
include/endpoint.h
+1
-0
ipv4.c
lib/ipv4.c
+1
-1
cmd_ip.c
shell/cmd_ip.c
+25
-2
cmd_mac.c
shell/cmd_mac.c
+2
-1
shell.c
shell/shell.c
+36
-1
shell.h
shell/shell.h
+4
-0
shell.mk
shell/shell.mk
+2
-1
No files found.
dev/endpoint.c
View file @
4e384293
...
...
@@ -47,7 +47,7 @@ void pcs_write(int location, int value)
}
/* MAC address setting */
static
void
set_mac_addr
(
uint8_t
dev_addr
[])
void
set_mac_addr
(
uint8_t
dev_addr
[])
{
EP
->
MACL
=
((
uint32_t
)
dev_addr
[
2
]
<<
24
)
|
((
uint32_t
)
dev_addr
[
3
]
<<
16
)
...
...
@@ -101,7 +101,7 @@ int ep_enable(int enabled, int autoneg)
/* Disable the endpoint */
EP
->
ECR
=
0
;
mprintf
(
"ID: %x"
,
EP
->
IDCODE
);
mprintf
(
"ID: %x
\n
"
,
EP
->
IDCODE
);
/* Load default packet classifier rules - see ep_pfilter.c for details */
pfilter_init_default
();
...
...
include/endpoint.h
View file @
4e384293
...
...
@@ -19,6 +19,7 @@ NOT=7
void
ep_init
(
uint8_t
mac_addr
[]);
void
get_mac_addr
(
uint8_t
dev_addr
[]);
void
set_mac_addr
(
uint8_t
dev_addr
[]);
int
ep_enable
(
int
enabled
,
int
autoneg
);
int
ep_link_up
(
uint16_t
*
lpa
);
int
ep_get_deltas
(
uint32_t
*
delta_tx
,
uint32_t
*
delta_rx
);
...
...
lib/ipv4.c
View file @
4e384293
...
...
@@ -28,7 +28,7 @@ void ipv4_init(const char* if_name, uint32_t ip) {
arp_init
(
if_name
);
icmp_init
(
if_name
);
TRACE_DEV
(
"My IP: %d.%d.%d.%d
\n
"
,
myIP
[
0
],
myIP
[
1
],
myIP
[
2
],
myIP
[
3
]);
//
TRACE_DEV("My IP: %d.%d.%d.%d\n", myIP[0], myIP[1], myIP[2], myIP[3]);
}
void
ipv4_poll
(
void
)
{
...
...
shell/cmd_ip.c
View file @
4e384293
...
...
@@ -6,8 +6,31 @@
#include "shell.h"
#include "../lib/ipv4.h"
static
decode_ip
(
const
char
*
str
,
unsigned
char
*
ip
)
{
int
i
,
x
;
/* Don't try to detect bad input; need small code */
for
(
i
=
0
;
i
<
4
;
++
i
)
{
str
=
fromdec
(
str
,
&
x
);
ip
[
i
]
=
x
;
if
(
*
str
==
'.'
)
++
str
;
}
}
int
cmd_ip
(
const
char
*
args
[])
{
mprintf
(
"My IP-address: %d.%d.%d.%d
\n
"
,
myIP
[
0
],
myIP
[
1
],
myIP
[
2
],
myIP
[
3
]);
unsigned
char
ip
[
4
];
if
(
!
args
[
0
]
||
!
strcasecmp
(
args
[
0
],
"get"
))
{
/* get current IP */
memcpy
(
ip
,
myIP
,
4
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"set"
)
&&
args
[
1
])
{
decode_ip
(
args
[
1
],
ip
);
memcpy
(
myIP
,
ip
,
4
);
}
else
{
return
-
EINVAL
;
}
mprintf
(
"IP-address: %d.%d.%d.%d
\n
"
,
ip
[
0
],
ip
[
1
],
ip
[
2
],
ip
[
3
]);
}
shell/cmd_mac.c
View file @
4e384293
...
...
@@ -17,7 +17,7 @@ static decode_mac(const char *str, unsigned char* mac) {
}
}
int
cmd_
ip
(
const
char
*
args
[])
int
cmd_
mac
(
const
char
*
args
[])
{
unsigned
char
mac
[
6
];
...
...
@@ -26,6 +26,7 @@ int cmd_ip(const char *args[])
get_mac_addr
(
mac
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"getp"
))
{
/* get persistent MAC */
get_mac_addr
(
mac
);
get_persistent_mac
(
mac
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"set"
)
&&
args
[
1
])
{
decode_mac
(
args
[
1
],
mac
);
...
...
shell/shell.c
View file @
4e384293
...
...
@@ -46,6 +46,7 @@ static const struct shell_cmd cmds_list[] = {
{
"time"
,
cmd_time
},
{
"sfp"
,
cmd_sfp
},
{
"ip"
,
cmd_ip
},
{
"mac"
,
cmd_mac
},
{
NULL
,
NULL
}
};
...
...
@@ -136,7 +137,7 @@ void shell_init()
env_init
();
cmd_len
=
cmd_pos
=
0
;
state
=
SH_PROMPT
;
//
mprintf("\033[2J\033[1;1H");
mprintf
(
"
\033
[2J
\033
[1;1H"
);
}
void
shell_interactive
()
...
...
@@ -228,3 +229,37 @@ void shell_interactive()
break
;
}
}
const
char
*
fromhex
(
const
char
*
hex
,
int
*
v
)
{
int
o
=
0
;
for
(;
*
hex
;
++
hex
)
{
if
(
*
hex
>=
'0'
&&
*
hex
<=
'9'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'0'
);
}
else
if
(
*
hex
>=
'A'
&&
*
hex
<=
'F'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'A'
)
+
10
;
}
else
if
(
*
hex
>=
'a'
&&
*
hex
<=
'f'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'a'
)
+
10
;
}
else
{
break
;
}
}
*
v
=
o
;
return
hex
;
}
const
char
*
fromdec
(
const
char
*
dec
,
int
*
v
)
{
int
o
=
0
;
for
(;
*
dec
;
++
dec
)
{
if
(
*
dec
>=
'0'
&&
*
dec
<=
'9'
)
{
o
=
(
o
*
10
)
+
(
*
dec
-
'0'
);
}
else
{
break
;
}
}
*
v
=
o
;
return
dec
;
}
shell/shell.h
View file @
4e384293
#ifndef __SHELL_H
#define __SHELL_H
const
char
*
fromhex
(
const
char
*
hex
,
int
*
v
);
const
char
*
fromdec
(
const
char
*
dec
,
int
*
v
);
int
cmd_gui
(
const
char
*
args
[]);
int
cmd_pll
(
const
char
*
args
[]);
int
cmd_sfp
(
const
char
*
args
[]);
...
...
@@ -12,6 +15,7 @@ int cmd_mode(const char *args[]);
int
cmd_measure_t24p
(
const
char
*
args
[]);
int
cmd_time
(
const
char
*
args
[]);
int
cmd_ip
(
const
char
*
args
[]);
int
cmd_mac
(
const
char
*
args
[]);
int
cmd_env
(
const
char
*
args
[]);
int
cmd_saveenv
(
const
char
*
args
[]);
...
...
shell/shell.mk
View file @
4e384293
...
...
@@ -9,4 +9,5 @@ OBJS_SHELL = shell/shell.o \
shell/cmd_measure_t24p.o \
shell/cmd_time.o \
shell/cmd_gui.o \
shell/cmd_ip.o
shell/cmd_ip.o \
shell/cmd_mac.o
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment