Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tommy Olofsson
LabComm
Commits
a4d22b52
Commit
a4d22b52
authored
Dec 14, 2011
by
Sven Robertz
Browse files
parameters for eth if name and dest MAC addr for thr examples
parent
35f90c3d
Changes
6
Hide whitespace changes
Inline
Side-by-side
examples/simple_java/thr_decoder.c
View file @
a4d22b52
...
...
@@ -24,8 +24,20 @@ int main(int argc, char *argv[]) {
unsigned
short
freq
=
1000
;
/* milliseconds */
unsigned
char
data
[
200
];
char
*
filename
=
argv
[
1
];
if
(
-
1
==
thr_init
(
"eth2"
))
char
*
ifname
=
argv
[
1
];
char
*
dest_mac_str
=
argv
[
2
];
if
(
argc
!=
3
)
{
printf
(
"usage: thr_encoder ethN xx:xx:xx:xx:xx:xx
\n
"
);
return
1
;
}
if
(
parse_MAC_address
(
dest_mac_str
,
dest_mac
))
{
printf
(
"failed to parse dest MAC address
\n
"
);
return
1
;
}
if
(
-
1
==
thr_init
(
ifname
))
{
printf
(
"Throttle Init failure."
);
}
...
...
examples/simple_java/thr_encoder.c
View file @
a4d22b52
...
...
@@ -10,13 +10,26 @@ int main(int argc, char *argv[]) {
struct
thr_chn_t
*
p_thr_chn
=
NULL
;
struct
labcomm_encoder
*
encoder
;
int
i
,
j
;
unsigned
char
dest_mac
[
ETH_ADR_SIZE
]
=
{
0x00
,
0x09
,
0x6b
,
0x10
,
0xf3
,
0x80
};
/* other host MAC address, hardcoded...... :-( */
// unsigned char dest_mac[ETH_ADR_SIZE] = {0x00, 0x09, 0x6b, 0x10, 0xf3, 0x80}; /* other host MAC address, hardcoded...... :-( */
unsigned
char
dest_mac
[
ETH_ADR_SIZE
]
=
{
0x00
,
0x09
,
0x6b
,
0xe3
,
0x81
,
0xbf
};
/* other host MAC address, hardcoded...... :-( */
unsigned
char
chn_id
=
0x01
;
unsigned
short
frag_size
=
60
;
unsigned
short
freq
=
1000
;
/* milliseconds */
char
*
filename
=
argv
[
1
];
if
(
-
1
==
thr_init
(
"eth0"
))
char
*
ifname
=
argv
[
1
];
char
*
dest_mac_str
=
argv
[
2
];
if
(
argc
!=
3
)
{
printf
(
"usage: thr_encoder ethN xx:xx:xx:xx:xx:xx
\n
"
);
return
1
;
}
if
(
parse_MAC_address
(
dest_mac_str
,
dest_mac
))
{
printf
(
"failed to parse dest MAC address
\n
"
);
return
1
;
}
if
(
-
1
==
thr_init
(
ifname
))
{
printf
(
"Throttle Init failure."
);
}
...
...
examples/simple_java/udp_compile.sh
View file @
a4d22b52
gcc
-o
udp_encoder
-L
../../lib/c
-I
.
-I
../../lib/c udp_encoder.c gen/simple.c ../../lib/c/labcomm_udp_reader_writer.c ../../lib/c/udp_hack.c
-llabcomm
gcc
-g
-o
udp_encoder
-L
../../lib/c
-I
.
-I
../../lib/c udp_encoder.c gen/simple.c ../../lib/c/labcomm_udp_reader_writer.c ../../lib/c/udp_hack.c
-llabcomm
gcc
-o
udp_decoder
-L
../../lib/c
-I
.
-I
../../lib/c udp_decoder.c gen/simple.c ../../lib/c/labcomm_udp_reader_writer.c ../../lib/c/udp_hack.c
-llabcomm
gcc
-g
-o
udp_decoder
-L
../../lib/c
-I
.
-I
../../lib/c udp_decoder.c gen/simple.c ../../lib/c/labcomm_udp_reader_writer.c ../../lib/c/udp_hack.c
-llabcomm
lib/c/Makefile
View file @
a4d22b52
liblabcomm.a
:
labcomm.o labcomm_fd_reader_writer.o
ar
-r
liblabcomm.a labcomm.o labcomm_fd_reader_writer.o
CC
=
gcc
CFLAGS
=
-g
liblabcomm.a
:
labcomm.o labcomm_fd_reader_writer.o ethaddr.o
ar
-r
liblabcomm.a labcomm.o labcomm_fd_reader_writer.o ethaddr.o
labcomm.o
:
labcomm.c labcomm.h labcomm_private.h
gcc
-c
labcomm.c
labcomm_fd_reader_writer.o
:
labcomm_fd_reader_writer.c labcomm_fd_reader_writer.h labcomm.h labcomm_private.h
gcc
-c
labcomm_fd_reader_writer.c
ethaddr.o
:
ethaddr.c
clean
:
rm
*
.o
...
...
lib/c/ethaddr.c
0 → 100644
View file @
a4d22b52
#include <stdio.h>
#include "ethaddr.h"
/* parse a string on the format 00:01:02:0d:0e:0f into a char array
* the mac_addr argument must be at least six bytes.
* returns 0 on success, or -1 on error
*/
int
parse_MAC_address
(
const
char
*
str
,
unsigned
char
mac_addr
[])
{
int
res
=
sscanf
(
str
,
"%x:%x:%x:%x:%x:%x"
,
&
mac_addr
[
0
],
&
mac_addr
[
1
],
&
mac_addr
[
2
],
&
mac_addr
[
3
],
&
mac_addr
[
4
],
&
mac_addr
[
5
]);
return
(
res
==
6
?
0
:
-
1
);
}
#if 0
/* test program */
int main(int argc, char *argv[])
{
int i;
unsigned char a[6];
int res = parse_MAC_address(argv[1], a);
if(res) {
perror("Failed to parse MAC address");
}
printf("%x.%x.%x.%x.%x.%x\n", a[0], a[1], a[2], a[3], a[4], a[5]);
return 0;
}
#endif
lib/c/ethaddr.h
0 → 100644
View file @
a4d22b52
#ifndef ETHADDR_H
#define ETHADDR_H
/* parse a string on the format 00:01:02:0d:0e:0f into a char array
* the mac_addr argument must be at least six bytes.
* returns 0 on success, or -1 on error
*/
int
parse_MAC_address
(
const
char
*
str
,
unsigned
char
mac_addr
[]);
#endif
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