RE: [netsniff-ng] Replay pcap file on Xenomai kernel in real time

2016-02-01 Thread Umair Ali
Hello Tobias,

I have read the read_pcap function. I am not expert in C just a beginner. I 
have understand the basic flow from the read_pcap function but still not fully. 
I am using the real time kernel Xenomai 3.0.1 and it uses the real time 
Ethernet driver and hence the name of the Ethernet interface is 'rteth'. If you 
read this link 
https://xenomai.org/2014/08/porting-a-linux-application-to-xenomai-dual-kernel/ 
which explains that how I can port the Linux application to the xenomai. As I 
am not expert therefore I am asking you that can I port the netsniff-ng tool to 
xenomai. I can ask the xenomai expert but you have build this tool and you can 
easily understand therefore I asked you. Or can I send the packet after 10 
µsecs in non-real time Linux. Can you provide me the separate code of reading 
the pcap file so I can run on xenomai. Sorry for being asking so many questions.

Thanks & Br
Ali
-Original Message-
From: Tobias Klauser [mailto:tklau...@distanz.ch] 
Sent: January-27-16 5:02 PM
To: Umair Ali
Cc: netsniff-ng@googlegroups.com
Subject: Re: [netsniff-ng] Replay pcap file on Xenomai kernel in real time

On 2016-01-27 at 15:15:01 +0100, Umair Ali  wrote:
> Hi Tobias,
> 
> Thanks for the quick reply. I have read pcap_mm.c file but cannot understand 
> the flow of the code. Can you explain me the flow that once the pcap file is 
> open using mmap then how it is further processed to extract packet by packet 
> and replay. Is it possible with netsniff-ng to send packet every 5micro secs 
> or less. 

The mmap pcap functions (like the scatter-gather and the standard file i/o 
functions) are wired up in struct pcap_file_ops *pcap_ops and then used by the 
respective functions in netsniff-ng.cx according to the pcap access method is 
set in ctx->pcap (PCAP_OPS_MM in case of mmap).
read_pcap in netsniff-ng.c is probably most interesting to you.

HTH
Tobias

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 3/7] trafgen: eth: Add setting next protocol id

2016-02-01 Thread Vadim Kochan
Move setting next protocol id field from higher protocols (ARP, IPv4)
to Ethernet. It makes code little more generic w/o checking each lower
protocol and setting specific field id.

Signed-off-by: Vadim Kochan 
---
 trafgen_l2.c | 24 +++-
 trafgen_l3.c |  4 +---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/trafgen_l2.c b/trafgen_l2.c
index 529dc36..c0e92a3 100644
--- a/trafgen_l2.c
+++ b/trafgen_l2.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 
+#include "die.h"
 #include "built_in.h"
 #include "trafgen_l2.h"
 #include "trafgen_proto.h"
@@ -16,6 +17,27 @@ static struct proto_field eth_fields[] = {
{ .id = ETH_TYPE, .len = 2, .offset = 12 },
 };
 
+static void eth_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)
+{
+   uint16_t eth_type;
+
+   switch(pid) {
+   case PROTO_ARP:
+   eth_type = ETH_P_ARP;
+   break;
+   case PROTO_IP4:
+   eth_type = ETH_P_IP;
+   break;
+   case PROTO_IP6:
+   eth_type = ETH_P_IPV6;
+   break;
+   default:
+   panic("eth: Not supported protocol id %u\n", pid);
+   }
+
+   proto_field_set_default_be16(hdr, ETH_TYPE, eth_type);
+}
+
 static void eth_header_init(struct proto_hdr *hdr)
 {
proto_header_fields_add(hdr, eth_fields, array_size(eth_fields));
@@ -27,6 +49,7 @@ static struct proto_hdr eth_hdr = {
.id = PROTO_ETH,
.layer  = PROTO_L2,
.header_init= eth_header_init,
+   .set_next_proto = eth_set_next_proto,
 };
 
 static struct proto_field arp_fields[] = {
@@ -51,7 +74,6 @@ static void arp_header_init(struct proto_hdr *hdr)
uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
proto_field_set_default_bytes(lower, ETH_DST_ADDR, bcast);
-   proto_field_set_default_be16(lower, ETH_TYPE, ETH_P_ARP);
}
 
proto_header_fields_add(hdr, arp_fields, array_size(arp_fields));
diff --git a/trafgen_l3.c b/trafgen_l3.c
index 9e5126a..58eaa01 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -37,9 +37,7 @@ static void ipv4_header_init(struct proto_hdr *hdr)
 
lower = proto_lower_default_add(hdr, PROTO_ETH);
 
-   if (lower->id == PROTO_ETH)
-   proto_field_set_default_be16(lower, ETH_TYPE, ETH_P_IP);
-   else if (lower->id == PROTO_IP4)
+   if (lower->id == PROTO_IP4)
proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_IPIP);
 
proto_header_fields_add(hdr, ipv4_fields, array_size(ipv4_fields));
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 2/7] trafgen: proto: Add set_next_proto callback to struct proto_hdr

2016-02-01 Thread Vadim Kochan
Add set_next_proto callback to proto_hdr struct to allow lower
protocol set next protocol id by enum proto_id.

Extended proto_lower_default_add(...) function to take upper protocol
to delegate it's id to lower protocol to set next protocol field.

Signed-off-by: Vadim Kochan 
---
 trafgen_l2.c|  2 +-
 trafgen_l3.c|  2 +-
 trafgen_l4.c|  2 +-
 trafgen_proto.c | 19 ++-
 trafgen_proto.h |  4 +++-
 5 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/trafgen_l2.c b/trafgen_l2.c
index 5600c24..529dc36 100644
--- a/trafgen_l2.c
+++ b/trafgen_l2.c
@@ -45,7 +45,7 @@ static void arp_header_init(struct proto_hdr *hdr)
 {
struct proto_hdr *lower;
 
-   lower = proto_lower_default_add(PROTO_ETH);
+   lower = proto_lower_default_add(hdr, PROTO_ETH);
 
if (lower->id == PROTO_ETH) {
uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
diff --git a/trafgen_l3.c b/trafgen_l3.c
index 5e47a36..9e5126a 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -35,7 +35,7 @@ static void ipv4_header_init(struct proto_hdr *hdr)
 {
struct proto_hdr *lower;
 
-   lower = proto_lower_default_add(PROTO_ETH);
+   lower = proto_lower_default_add(hdr, PROTO_ETH);
 
if (lower->id == PROTO_ETH)
proto_field_set_default_be16(lower, ETH_TYPE, ETH_P_IP);
diff --git a/trafgen_l4.c b/trafgen_l4.c
index f3d8542..1505b43 100644
--- a/trafgen_l4.c
+++ b/trafgen_l4.c
@@ -45,7 +45,7 @@ static void udp_header_init(struct proto_hdr *hdr)
 {
struct proto_hdr *lower;
 
-   lower = proto_lower_default_add(PROTO_IP4);
+   lower = proto_lower_default_add(hdr, PROTO_IP4);
 
if (lower->id == PROTO_IP4)
proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_UDP);
diff --git a/trafgen_proto.c b/trafgen_proto.c
index 37cbab6..c6b9e2e 100644
--- a/trafgen_proto.c
+++ b/trafgen_proto.c
@@ -155,18 +155,27 @@ void proto_header_finish(struct proto_hdr *hdr)
hdr->header_finish(hdr);
 }
 
-struct proto_hdr *proto_lower_default_add(enum proto_id pid)
+struct proto_hdr *proto_lower_default_add(struct proto_hdr *hdr,
+ enum proto_id pid)
 {
+   struct proto_hdr *current;
+
if (headers_count > 0) {
-   struct proto_hdr *current = proto_current_header();
+   current = proto_current_header();
 
if (current->layer >= proto_header_by_id(pid)->layer)
-   return current;
+   goto set_proto;
if (current->id == pid)
-   return current;
+   goto set_proto;
}
 
-   return proto_header_init(pid);
+   current = proto_header_init(pid);
+
+set_proto:
+   if (current->set_next_proto)
+   current->set_next_proto(current, hdr->id);
+
+   return current;
 }
 
 static void __proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid,
diff --git a/trafgen_proto.h b/trafgen_proto.h
index 2d74f4c..491e079 100644
--- a/trafgen_proto.h
+++ b/trafgen_proto.h
@@ -50,6 +50,7 @@ struct proto_hdr {
void (*header_init)(struct proto_hdr *hdr);
void (*header_finish)(struct proto_hdr *hdr);
void (*packet_finish)(struct proto_hdr *hdr);
+   void (*set_next_proto)(struct proto_hdr *hdr, enum proto_id pid);
 };
 
 extern void protos_init(const char *dev);
@@ -58,7 +59,8 @@ extern void proto_header_register(struct proto_hdr *hdr);
 extern struct proto_hdr *proto_header_init(enum proto_id pid);
 extern void proto_header_finish(struct proto_hdr *hdr);
 extern void proto_packet_finish(void);
-extern struct proto_hdr *proto_lower_default_add(enum proto_id pid);
+extern struct proto_hdr *proto_lower_default_add(struct proto_hdr *hdr,
+enum proto_id pid);
 
 extern struct proto_hdr *proto_current_header(void);
 extern struct proto_hdr *proto_lower_header(struct proto_hdr *hdr);
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 4/7] trafgen: ipv4: Add setting next protocol id

2016-02-01 Thread Vadim Kochan
Move setting lower protocol id field value from UDP & TCP
protocols to IPv4 only, so lower layer will know exactly value
to set in protocol id field.

Signed-off-by: Vadim Kochan 
---
 trafgen_l3.c | 30 --
 trafgen_l4.c | 16 ++--
 2 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/trafgen_l3.c b/trafgen_l3.c
index 58eaa01..0e923e0 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -5,6 +5,7 @@
 
 #include 
 
+#include "die.h"
 #include "csum.h"
 #include "built_in.h"
 #include "trafgen_l2.h"
@@ -33,12 +34,7 @@ static struct proto_field ipv4_fields[] = {
 
 static void ipv4_header_init(struct proto_hdr *hdr)
 {
-   struct proto_hdr *lower;
-
-   lower = proto_lower_default_add(hdr, PROTO_ETH);
-
-   if (lower->id == PROTO_IP4)
-   proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_IPIP);
+   proto_lower_default_add(hdr, PROTO_ETH);
 
proto_header_fields_add(hdr, ipv4_fields, array_size(ipv4_fields));
 
@@ -65,11 +61,33 @@ static void ipv4_packet_finish(struct proto_hdr *hdr)
}
 }
 
+static void ipv4_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)
+{
+   uint8_t ip_proto;
+
+   switch(pid) {
+   case PROTO_IP4:
+   ip_proto = IPPROTO_IPIP;
+   break;
+   case PROTO_UDP:
+   ip_proto = IPPROTO_UDP;
+   break;
+   case PROTO_TCP:
+   ip_proto = IPPROTO_TCP;
+   break;
+   default:
+   panic("ipv4: Not supported protocol id %u\n", pid);
+   }
+
+   proto_field_set_default_u8(hdr, IP4_PROTO, ip_proto);
+}
+
 static struct proto_hdr ipv4_hdr = {
.id = PROTO_IP4,
.layer  = PROTO_L3,
.header_init= ipv4_header_init,
.packet_finish  = ipv4_packet_finish,
+   .set_next_proto = ipv4_set_next_proto,
 };
 
 void protos_l3_init(void)
diff --git a/trafgen_l4.c b/trafgen_l4.c
index 1505b43..64aada4 100644
--- a/trafgen_l4.c
+++ b/trafgen_l4.c
@@ -43,12 +43,7 @@ static struct proto_field tcp_fields[] = {
 
 static void udp_header_init(struct proto_hdr *hdr)
 {
-   struct proto_hdr *lower;
-
-   lower = proto_lower_default_add(hdr, PROTO_IP4);
-
-   if (lower->id == PROTO_IP4)
-   proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_UDP);
+   proto_lower_default_add(hdr, PROTO_IP4);
 
proto_header_fields_add(hdr, udp_fields, array_size(udp_fields));
 }
@@ -85,14 +80,7 @@ static struct proto_hdr udp_hdr = {
 
 static void tcp_header_init(struct proto_hdr *hdr)
 {
-   struct proto_hdr *lower;
-
-   proto_lower_default_add(PROTO_IP4);
-
-   lower = proto_current_header();
-
-   if (lower->id == PROTO_IP4)
-   proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_TCP);
+   proto_lower_default_add(hdr, PROTO_IP4);
 
proto_header_fields_add(hdr, tcp_fields, array_size(tcp_fields));
 
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 1/7] trafgen: proto: Simplify getting lower protocol after init

2016-02-01 Thread Vadim Kochan
Change proto_header_init(...) and proto_lower_default_add(...)
functions to return struct proto_hdr * to do not call
proto_current_header(...) after, so it makes more sense to get struct
proto_hdr * right after initializing protocol by id.

Signed-off-by: Vadim Kochan 
---
 trafgen_l2.c |  4 +---
 trafgen_l3.c |  3 +--
 trafgen_l4.c |  4 +---
 trafgen_parser.y |  3 +--
 trafgen_proto.c  | 17 ++---
 trafgen_proto.h  |  4 ++--
 6 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/trafgen_l2.c b/trafgen_l2.c
index 60da411..5600c24 100644
--- a/trafgen_l2.c
+++ b/trafgen_l2.c
@@ -45,9 +45,7 @@ static void arp_header_init(struct proto_hdr *hdr)
 {
struct proto_hdr *lower;
 
-   proto_lower_default_add(PROTO_ETH);
-
-   lower = proto_current_header();
+   lower = proto_lower_default_add(PROTO_ETH);
 
if (lower->id == PROTO_ETH) {
uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
diff --git a/trafgen_l3.c b/trafgen_l3.c
index 1771908..5e47a36 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -35,9 +35,8 @@ static void ipv4_header_init(struct proto_hdr *hdr)
 {
struct proto_hdr *lower;
 
-   proto_lower_default_add(PROTO_ETH);
+   lower = proto_lower_default_add(PROTO_ETH);
 
-   lower = proto_current_header();
if (lower->id == PROTO_ETH)
proto_field_set_default_be16(lower, ETH_TYPE, ETH_P_IP);
else if (lower->id == PROTO_IP4)
diff --git a/trafgen_l4.c b/trafgen_l4.c
index 7f80e74..f3d8542 100644
--- a/trafgen_l4.c
+++ b/trafgen_l4.c
@@ -45,9 +45,7 @@ static void udp_header_init(struct proto_hdr *hdr)
 {
struct proto_hdr *lower;
 
-   proto_lower_default_add(PROTO_IP4);
-
-   lower = proto_current_header();
+   lower = proto_lower_default_add(PROTO_IP4);
 
if (lower->id == PROTO_IP4)
proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_UDP);
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 1bacfd0..091d6b2 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -334,8 +334,7 @@ static void set_dynamic_incdec(uint8_t start, uint8_t stop, 
uint8_t stepping,
 
 static void proto_add(enum proto_id pid)
 {
-   proto_header_init(pid);
-   hdr = proto_current_header();
+   hdr = proto_header_init(pid);
 }
 
 %}
diff --git a/trafgen_proto.c b/trafgen_proto.c
index 3cbf34e..37cbab6 100644
--- a/trafgen_proto.c
+++ b/trafgen_proto.c
@@ -131,7 +131,7 @@ bool proto_field_is_set(struct proto_hdr *hdr, uint32_t fid)
return field ? field->is_set : false;
 }
 
-void proto_header_init(enum proto_id pid)
+struct proto_hdr *proto_header_init(enum proto_id pid)
 {
struct proto_hdr *hdr = proto_header_by_id(pid);
struct proto_hdr *new_hdr;
@@ -146,6 +146,7 @@ void proto_header_init(enum proto_id pid)
new_hdr->header_init(new_hdr);
 
headers[headers_count++] = new_hdr;
+   return new_hdr;
 }
 
 void proto_header_finish(struct proto_hdr *hdr)
@@ -154,16 +155,18 @@ void proto_header_finish(struct proto_hdr *hdr)
hdr->header_finish(hdr);
 }
 
-void proto_lower_default_add(enum proto_id pid)
+struct proto_hdr *proto_lower_default_add(enum proto_id pid)
 {
if (headers_count > 0) {
-   if (proto_current_header()->layer >= 
proto_header_by_id(pid)->layer)
-   return;
-   if (proto_current_header()->id == pid)
-   return;
+   struct proto_hdr *current = proto_current_header();
+
+   if (current->layer >= proto_header_by_id(pid)->layer)
+   return current;
+   if (current->id == pid)
+   return current;
}
 
-   proto_header_init(pid);
+   return proto_header_init(pid);
 }
 
 static void __proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid,
diff --git a/trafgen_proto.h b/trafgen_proto.h
index 02a8cc5..2d74f4c 100644
--- a/trafgen_proto.h
+++ b/trafgen_proto.h
@@ -55,10 +55,10 @@ struct proto_hdr {
 extern void protos_init(const char *dev);
 extern void proto_header_register(struct proto_hdr *hdr);
 
-extern void proto_header_init(enum proto_id pid);
+extern struct proto_hdr *proto_header_init(enum proto_id pid);
 extern void proto_header_finish(struct proto_hdr *hdr);
 extern void proto_packet_finish(void);
-extern void proto_lower_default_add(enum proto_id pid);
+extern struct proto_hdr *proto_lower_default_add(enum proto_id pid);
 
 extern struct proto_hdr *proto_current_header(void);
 extern struct proto_hdr *proto_lower_header(struct proto_hdr *hdr);
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 6/7] trafgen: parser: Add syntax for VLAN header creating

2016-02-01 Thread Vadim Kochan
Add 'vlan()' function to generate VLAN header.

Fields supported:

tpid|proto  Set TPID (Tag Protocol Identifier) (default 0x8100)
1ad Set TPID field as 0x88a8
1q  Set TPID field as 0x8100
tci Set TCI (Tag Control Information) (default 0)
pcp Set PCP (Priority Code Point) (PCP) (default 0)
dei|cfi Set DEI (Drop Eligible Indicator) (default 0)
id  Set VID (VLAN Identifier) (default 0)

VLAN identifier might be specified like just number or via 'id' parameter.

Examples:

{ eth(), vlan(1), ipv4() }
{ vlan(1, 1ad), vlan(100, pcp=3), ipv4() }

Signed-off-by: Vadim Kochan 
---
 trafgen_lexer.l  |  9 +
 trafgen_parser.y | 39 +++
 2 files changed, 48 insertions(+)

diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index ef7ec2a..e1d1a3f 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -112,6 +112,14 @@ ip4_addr   ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)
 "saddr"|"sa"   { return K_SADDR; }
 [e]?"type" { return K_ETYPE; }
 
+   /* VLAN (802.1Q & 802.1ad) */
+"tpid" { return K_TPID; }
+"tci"  { return K_TCI; }
+"pcp"  { return K_PCP; }
+"dei"|"cfi"{ return K_DEI; }
+"1ad"  { return K_1AD; }
+"1q"   { return K_1Q; }
+
/* ARP */
 "sha"|"smac"   { return K_SHA; }
 "spa"|"sip"{ return K_SPA; }
@@ -158,6 +166,7 @@ ip4_addr([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)
 "urgptr"   { return K_URG_PTR; }
 
 "eth"  { return K_ETH; }
+"vlan" { return K_VLAN; }
 "arp"  { return K_ARP; }
 "ip4"|"ipv4"   { return K_IP4; }
 "udp"  { return K_UDP; }
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 091d6b2..5f5b79d 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "xmalloc.h"
 #include "trafgen_parser.tab.h"
@@ -354,8 +355,10 @@ static void proto_add(enum proto_id pid)
 %token K_PROT K_TTL K_DSCP K_ECN K_TOS K_LEN K_ID K_FLAGS K_FRAG K_IHL K_VER 
K_CSUM K_DF K_MF
 %token K_SPORT K_DPORT
 %token K_SEQ K_ACK_SEQ K_DOFF K_CWR K_ECE K_URG K_ACK K_PSH K_RST K_SYN K_FIN 
K_WINDOW K_URG_PTR
+%token K_TPID K_TCI K_PCP K_DEI K_1Q K_1AD
 
 %token K_ETH
+%token K_VLAN
 %token K_ARP
 %token K_IP4
 %token K_UDP K_TCP
@@ -579,6 +582,7 @@ ddec
 
 proto
: eth_proto { }
+   | vlan_proto { }
| arp_proto { }
| ip4_proto { }
| udp_proto { }
@@ -613,6 +617,41 @@ eth_field
{ proto_field_set_be16(hdr, ETH_TYPE, $5); }
;
 
+vlan_proto
+   : vlan '(' vlan_param_list ')' { }
+   ;
+
+vlan
+   : K_VLAN { proto_add(PROTO_VLAN); }
+   ;
+
+vlan_param_list
+   : { }
+   | vlan_field { }
+   | vlan_field delimiter vlan_param_list { }
+   ;
+
+vlan_field
+   : K_TPID  skip_white '=' skip_white number
+   { proto_field_set_be16(hdr, VLAN_TPID, $5); }
+   | K_PROT  skip_white '=' skip_white number
+   { proto_field_set_be16(hdr, VLAN_TPID, $5); }
+   | K_1Q
+   { proto_field_set_be16(hdr, VLAN_TPID, ETH_P_8021Q); }
+   | K_1AD
+   { proto_field_set_be16(hdr, VLAN_TPID, ETH_P_8021AD); }
+   | K_TCI  skip_white '=' skip_white number
+   { proto_field_set_be16(hdr, VLAN_TCI, $5); }
+   | K_PCP skip_white '=' skip_white number
+   { proto_field_set_be16(hdr, VLAN_PCP, $5); }
+   | K_DEI skip_white '=' skip_white number
+   { proto_field_set_be16(hdr, VLAN_DEI, $5); }
+   | K_ID skip_white '=' skip_white number
+   { proto_field_set_be16(hdr, VLAN_VID, $5); }
+   | number
+   { proto_field_set_be16(hdr, VLAN_VID, $1); }
+   ;
+
 arp_proto
: arp '(' arp_param_list ')' { }
;
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 7/7] trafgen: man: Add help for VLAN header function

2016-02-01 Thread Vadim Kochan
Add usage, syntax & parameters description for 'vlan()' function.

Signed-off-by: Vadim Kochan 
---
 trafgen.8 | 43 +++
 1 file changed, 43 insertions(+)

diff --git a/trafgen.8 b/trafgen.8
index 207cfc5..1fe5536 100644
--- a/trafgen.8
+++ b/trafgen.8
@@ -307,6 +307,49 @@ Supported protocol headers:
 - Ethernet type (default: 0)
 .in -4
 
+.I VLAN
+:
+.B vlan(tpid=, id=, dei=, tci=, pcp=,
+.B 1q, 1ad, )
+.sp
+.in +4
+.B tpid|prot|proto
+- Tag Protocol Identifier (TPID) (default: 0x8100)
+.sp
+.B tci
+- Tag Control Information (TCI) field (VLAN Id + PCP + DEI) (default: 0)
+.sp
+.B dei|cfi
+- Drop Eligible Indicator (DEI) (formerly Canonical Format Indicator (CFI)) 
(default: 0)
+.sp
+.B pcp
+- Priority code point (PCP) (default: 0)
+.sp
+.B id
+- VLAN Identifier (default: 0)
+.sp
+.B 
+- Set VLAN Identifier field
+.sp
+.B 1q
+- Set 802.1q header (TPID: 0x8100)
+.sp
+.B 1ad
+- Set 802.1ad header (TPID: 0x88a8)
+.sp
+.in -4
+By default, if the lower level header is Ethernet, its protocol field is set to
+0x8100 (802.1q).
+Example of adding VLAN tag with id 100:
+.in +4
+.sp
+{ vlan(100) }
+.sp
+{ vlan(id=100, pcp=3) }
+.sp
+{ vlan(100, pcp=3) }
+.in -4
+
 .I ARP
 :
 .B arp(htype=, ptype=, op=, request,
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [netsniff-ng] Replay pcap file on Xenomai kernel in real time

2016-02-01 Thread Daniel Borkmann

On 02/01/2016 04:51 PM, Tobias Klauser wrote:

On 2016-02-01 at 15:38:28 +0100, Umair Ali  wrote:

[...]

Sorry, but reviewing a random dump of code (that doesn't even compile)
goes beyond the scope of what I'd consider support/help for netsniff-ng.


+1

Ali, I find your request very unreasonable. Tobias was kind enough
to point you to everything you need to look at and if it's for your
university project anyway, then consider the rest a learning process.
Wasting a maintainers precious time like this I consider rude.

Thank you,
Daniel

--
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [netsniff-ng] Replay pcap file on Xenomai kernel in real time

2016-02-01 Thread Tobias Klauser
On 2016-02-01 at 15:38:28 +0100, Umair Ali  wrote:
> Thanks a lot for the help offer. I can understand what you want to say. 
> 
> I need your feedback on the code which I have written. The flow of the code 
> is as follows
> - Reader the pcap file. the pcap file contained the captured Sampled Values 
> packets (IEC 61850 9-2 SV, Datalink layer lever)
> - The length of each packet is fixed which is 126 bytes and pcap only contain 
> SV packets.
> - The code below is opening pcap file and then mapping the file and closing 
> the pcap file
> - the Variable packet_index is used to point the start of every packet
> 
> It is very small code and it will few minutes to read. Please find the 
> attached file. I will appreciate your feedback and points of suggestions. 
> Thanks a lot once again and sorry for bugging you too much.

Sorry, but reviewing a random dump of code (that doesn't even compile)
goes beyond the scope of what I'd consider support/help for netsniff-ng.

As said, I'm happy to help with any problems you encounter specific to
the netsniff-ng toolkit or help you get patches integrated that make
netsniff-ng work better in your environment/application.

Good luck
Tobias

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.