summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-10-20 12:15:02 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:38 +0200
commit72e7d53f97aa42547da136d3a141c627f1833d40 (patch)
tree10ec2932573eb229cfee71254da6701215657604
parent3f9f7deaa165ce2f29ff953143663aa997509e48 (diff)
ASTARO: correctly handle in/out lladdr
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--output/ulogd_output_ASTARO.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/output/ulogd_output_ASTARO.c b/output/ulogd_output_ASTARO.c
index 310efb4..295ab56 100644
--- a/output/ulogd_output_ASTARO.c
+++ b/output/ulogd_output_ASTARO.c
@@ -184,21 +184,32 @@ lh_log_mac(const struct ulogd_pluginstance *pi, unsigned idx,
char *buf, size_t len)
{
const struct ulogd_key *in = pi->input.keys;
- char hwaddr[3 * ETH_ALEN];
+ unsigned char __src[ETH_ALEN], __dst[ETH_ALEN];
+ const unsigned char *src = NULL, *dst = NULL;
+ char *pch = buf, *end = buf + len;
- if (key_src_valid(&in[InOobIfiIn])) {
- if (ifi_hwaddr2str(key_src_u32(&in[InOobIfiIn]), hwaddr,
- sizeof(hwaddr)))
- snprintf(buf, len, "dstmac=\"%s\"", hwaddr);
- }
+ if (key_src_valid(&in[InRawMac])) { /* incoming packet */
+ src = key_src_ptr(&in[InRawMac]);
- if (key_src_valid(&in[InOobIfiOut])) {
- if (ifi_hwaddr2str(key_src_u32(&in[InOobIfiOut]), hwaddr,
- sizeof(hwaddr)))
- snprintf(buf, len, "srcmac=\"%s\"", hwaddr);
+ if (key_src_valid(&in[InOobIfiIn])) {
+ ifi_get_hwaddr(key_src_u32(&in[InOobIfiIn]), __dst);
+ dst = __dst;
+ }
+ } else { /* outgoing packet */
+ if (key_src_valid(&in[InOobIfiOut])) {
+ ifi_get_hwaddr(key_src_u32(&in[InOobIfiOut]), __src);
+ src = __src;
+ }
}
- return 0;
+ if (src)
+ pch += snprintf(pch, end - pch, "srcmac=\"%s\" ",
+ ether_ntoa((struct ether_addr *)src));
+ if (dst)
+ pch += snprintf(pch, end - pch, "dstmac=\"%s\" ",
+ ether_ntoa((struct ether_addr *)dst));
+
+ return pch - buf;
}