<commit_before>/*
 * eth.h
 *
 * Ethernet.
 *
 * Copyright (c) 2000 <NAME> <<EMAIL>>
 *
 * $Id$
 */

#ifndef DNET_ETH_H
#define DNET_ETH_H

#define ETH_ADDR_LEN	6
#define ETH_ADDR_BITS	48
#define ETH_TYPE_LEN	2
#define ETH_CRC_LEN	4
#define ETH_HDR_LEN	14

#define ETH_LEN_MIN	64		/* minimum frame length with CRC */
#define ETH_LEN_MAX	1518		/* maximum frame length with CRC */

#define ETH_MTU		(ETH_LEN_MAX - ETH_HDR_LEN - ETH_CRC_LEN)
#define ETH_MIN		(ETH_LEN_MIN - ETH_HDR_LEN - ETH_CRC_LEN)

typedef struct eth_addr {
	u_char		data[ETH_ADDR_LEN];
} eth_addr_t;

struct eth_hdr {
	eth_addr_t	eth_dst;	/* destination address */
	eth_addr_t	eth_src;	/* source address */
	u_short		eth_type;	/* payload type */
};

/*
 * Ethernet payload types
 */
#define ETH_TYPE_PUP	0x0200		/* PUP protocol */
#define ETH_TYPE_IP	0x0800		/* IP protocol */
#define ETH_TYPE_ARP	0x0806		/* address resolution protocol */
#define ETH_TYPE_REVARP	0x8035		/* reverse addr resolution protocol */
#define ETH_TYPE_8021Q	0x8100		/* IEEE 802.1Q VLAN tagging */
#define ETH_TYPE_IPV6	0x86DD		/* IPv6 protocol */
#define ETH_TYPE_PPPOEDISC	0x8863	/* PPP Over Ethernet Discovery Stage */
#define ETH_TYPE_PPPOE	0x8864		/* PPP Over Ethernet Session Stage */
#define ETH_TYPE_LOOPBACK	0x9000	/* used to test interfaces */

#define ETH_IS_MULTICAST(ea)	(*(ea) & 0x01) /* is address mcast/bcast? */

#define ETH_ADDR_BROADCAST	"\xff\xff\xff\xff\xff\xff"

typedef struct eth_handle eth_t;

eth_t	*eth_open(char *device);
ssize_t	 eth_send(eth_t *e, const void *buf, size_t len);
int	 eth_close(eth_t *e);

#define eth_fill(h, dst, src, type) do {			\
	struct eth_hdr *eth_fill_p = (struct eth_hdr *)(h);	\
	memcpy(&eth_fill_p->eth_dst, &(dst), ETH_ADDR_LEN);	\
	memcpy(&eth_fill_p->eth_src, &(src), ETH_ADDR_LEN);	\
	eth_fill_p->eth_type = htons(type);			\
} while (0)

#endif /* DNET_ETH_H */<commit_msg>export eth_{set,get}<commit_after>/*
 * eth.h
 *
 * Ethernet.
 *
 * Copyright (c) 2000 <NAME> <<EMAIL>>
 *
 * $Id$
 */

#ifndef DNET_ETH_H
#define DNET_ETH_H

#define ETH_ADDR_LEN	6
#define ETH_ADDR_BITS	48
#define ETH_TYPE_LEN	2
#define ETH_CRC_LEN	4
#define ETH_HDR_LEN	14

#define ETH_LEN_MIN	64		/* minimum frame length with CRC */
#define ETH_LEN_MAX	1518		/* maximum frame length with CRC */

#define ETH_MTU		(ETH_LEN_MAX - ETH_HDR_LEN - ETH_CRC_LEN)
#define ETH_MIN		(ETH_LEN_MIN - ETH_HDR_LEN - ETH_CRC_LEN)

typedef struct eth_addr {
	u_char		data[ETH_ADDR_LEN];
} eth_addr_t;

struct eth_hdr {
	eth_addr_t	eth_dst;	/* destination address */
	eth_addr_t	eth_src;	/* source address */
	u_short		eth_type;	/* payload type */
};

/*
 * Ethernet payload types
 */
#define ETH_TYPE_PUP	0x0200		/* PUP protocol */
#define ETH_TYPE_IP	0x0800		/* IP protocol */
#define ETH_TYPE_ARP	0x0806		/* address resolution protocol */
#define ETH_TYPE_REVARP	0x8035		/* reverse addr resolution protocol */
#define ETH_TYPE_8021Q	0x8100		/* IEEE 802.1Q VLAN tagging */
#define ETH_TYPE_IPV6	0x86DD		/* IPv6 protocol */
#define ETH_TYPE_PPPOEDISC	0x8863	/* PPP Over Ethernet Discovery Stage */
#define ETH_TYPE_PPPOE	0x8864		/* PPP Over Ethernet Session Stage */
#define ETH_TYPE_LOOPBACK	0x9000	/* used to test interfaces */

#define ETH_IS_MULTICAST(ea)	(*(ea) & 0x01) /* is address mcast/bcast? */

#define ETH_ADDR_BROADCAST	"\xff\xff\xff\xff\xff\xff"

typedef struct eth_handle eth_t;

eth_t	*eth_open(char *device);
int	 eth_get(eth_t *e, eth_addr_t *ea);
int	 eth_set(eth_t *e, eth_addr_t *ea);
ssize_t	 eth_send(eth_t *e, const void *buf, size_t len);
int	 eth_close(eth_t *e);

#define eth_fill(h, dst, src, type) do {			\
	struct eth_hdr *eth_fill_p = (struct eth_hdr *)(h);	\
	memcpy(&eth_fill_p->eth_dst, &(dst), ETH_ADDR_LEN);	\
	memcpy(&eth_fill_p->eth_src, &(src), ETH_ADDR_LEN);	\
	eth_fill_p->eth_type = htons(type);			\
} while (0)

#endif /* DNET_ETH_H */
{'fraction_non_alphanumeric': 0.1210622233793283, 'fraction_numerical': 0.038531632387399116, 'mean_word_length': 4.306629834254144, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6093935', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1599, 'n_words': 385}