source: mainline/uspace/srv/net/ethip/ethip.h

Last change on this file was b4edc96, checked in by Jiri Svoboda <jiri@…>, 4 years ago

Rename and move addr48_t to eth_addr_t

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2021 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup ethip
30 * @{
31 */
32/**
33 * @file
34 * @brief
35 */
36
37#ifndef ETHIP_H_
38#define ETHIP_H_
39
40#include <adt/list.h>
41#include <async.h>
42#include <inet/addr.h>
43#include <inet/eth_addr.h>
44#include <inet/iplink_srv.h>
45#include <loc.h>
46#include <stddef.h>
47#include <stdint.h>
48
49typedef struct {
50 link_t link;
51 inet_addr_t addr;
52} ethip_link_addr_t;
53
54typedef struct ethip_nic {
55 link_t link;
56 service_id_t svc_id;
57 char *svc_name;
58 async_sess_t *sess;
59
60 iplink_srv_t iplink;
61 service_id_t iplink_sid;
62
63 /** MAC address */
64 eth_addr_t mac_addr;
65
66 /**
67 * List of IP addresses configured on this link
68 * (of the type ethip_link_addr_t)
69 */
70 list_t addr_list;
71} ethip_nic_t;
72
73/** Ethernet frame */
74typedef struct {
75 /** Destination Address */
76 eth_addr_t dest;
77 /** Source Address */
78 eth_addr_t src;
79 /** Ethertype or Length */
80 uint16_t etype_len;
81 /** Payload */
82 void *data;
83 /** Payload size */
84 size_t size;
85} eth_frame_t;
86
87/** ARP opcode */
88typedef enum {
89 /** Request */
90 aop_request,
91 /** Reply */
92 aop_reply
93} arp_opcode_t;
94
95/** ARP packet (for 48-bit MAC addresses and IPv4)
96 *
97 * Internal representation
98 */
99typedef struct {
100 /** Opcode */
101 arp_opcode_t opcode;
102 /** Sender hardware address */
103 eth_addr_t sender_hw_addr;
104 /** Sender protocol address */
105 addr32_t sender_proto_addr;
106 /** Target hardware address */
107 eth_addr_t target_hw_addr;
108 /** Target protocol address */
109 addr32_t target_proto_addr;
110} arp_eth_packet_t;
111
112/** Address translation table element */
113typedef struct {
114 link_t atrans_list;
115 addr32_t ip_addr;
116 eth_addr_t mac_addr;
117} ethip_atrans_t;
118
119extern errno_t ethip_iplink_init(ethip_nic_t *);
120extern errno_t ethip_received(iplink_srv_t *, void *, size_t);
121
122#endif
123
124/** @}
125 */
Note: See TracBrowser for help on using the repository browser.