-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathENETHDR.C
41 lines (35 loc) · 859 Bytes
/
ENETHDR.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Ethernet header conversion routines
* Copyright 1991 Phil Karn, KA9Q
*/
#include "global.h"
#if defined PC_EC || defined PACKET
#include "mbuf.h"
#include "enet.h"
/* Convert Ethernet header in host form to network mbuf */
struct mbuf *
htonether(ether,bp)
struct ether *ether;
struct mbuf *bp;
{
register char *cp;
bp = pushdown(bp,ETHERLEN);
cp = bp->data;
memcpy(cp,ether->dest,EADDR_LEN);
cp += EADDR_LEN;
memcpy(cp,ether->source,EADDR_LEN);
cp += EADDR_LEN;
put16(cp,ether->type);
return bp;
}
/* Extract Ethernet header */
int
ntohether(ether,bpp)
struct ether *ether;
struct mbuf **bpp;
{
pullup(bpp,ether->dest,EADDR_LEN);
pullup(bpp,ether->source,EADDR_LEN);
ether->type = pull16(bpp);
return ETHERLEN;
}
#endif /* PC_EC || PACKET */