Skip to content

Commit

Permalink
vlan
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Aug 9, 2014
1 parent c785661 commit e04e038
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,8 @@ main_scan(struct Masscan *masscan)
if (masscan->nmap.ttl)
template_set_ttl(parms->tmplset, masscan->nmap.ttl);

if (masscan->nic[0].is_vlan)
template_set_vlan(parms->tmplset, masscan->nic[0].vlan_id);


/*
Expand Down
30 changes: 30 additions & 0 deletions src/templ-pkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,36 @@ template_set_ttl(struct TemplateSet *tmplset, unsigned ttl)
}
}

void
template_set_vlan(struct TemplateSet *tmplset, unsigned vlan)
{
unsigned i;

for (i=0; i<tmplset->count; i++) {
struct TemplatePacket *tmpl = &tmplset->pkts[i];
unsigned char *px;

if (tmpl->length < 14)
continue;

px = (unsigned char*)malloc(tmpl->length + 4);
memcpy(px, tmpl->packet, 12);
memcpy(px+16, tmpl->packet+12, tmpl->length - 12);

px[12] = 0x81;
px[13] = 0x00;
px[14] = (unsigned char)(vlan>>8);
px[15] = (unsigned char)(vlan>>0);

tmpl->packet = px;
tmpl->length += 4;

tmpl->offset_ip += 4;
tmpl->offset_tcp += 4;
tmpl->offset_app += 4;
}
}



/***************************************************************************
Expand Down
1 change: 1 addition & 0 deletions src/templ-pkt.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@ unsigned template_get_source_ip(struct TemplateSet *tmplset);

void template_set_source_port(struct TemplateSet *tmplset, unsigned port);
void template_set_ttl(struct TemplateSet *tmplset, unsigned ttl);
void template_set_vlan(struct TemplateSet *tmplset, unsigned vlan);

#endif

0 comments on commit e04e038

Please sign in to comment.