source: mainline/uspace/srv/ethip/ethip.h@ 1cc8b42

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1cc8b42 was 56792a2, checked in by Jiri Svoboda <jiri@…>, 14 years ago

Read MAC address from NIC.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2012 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/iplink_srv.h>
43#include <loc.h>
44#include <sys/types.h>
45
46typedef struct {
47 link_t addr_list;
48 iplink_srv_addr_t addr;
49} ethip_link_addr_t;
50
51/** IEEE MAC-48 identifier */
52typedef struct {
53 /** MAC Address (in lowest 48 bits) */
54 uint64_t addr;
55} mac48_addr_t;
56
57typedef struct ethip_nic {
58 link_t nic_list;
59 service_id_t svc_id;
60 char *svc_name;
61 async_sess_t *sess;
62
63 iplink_srv_t iplink;
64 service_id_t iplink_sid;
65
66 /** MAC address */
67 mac48_addr_t mac_addr;
68 /** List of IP addresses configured on this link */
69 list_t addr_list; /* of ethip_link_addr_t */
70} ethip_nic_t;
71
72/** Ethernet frame */
73typedef struct {
74 /** Destination Address */
75 mac48_addr_t dest;
76 /** Source Address */
77 mac48_addr_t src;
78 /** Ethertype or Length */
79 uint16_t etype_len;
80 /** Payload */
81 void *data;
82 /** Payload size */
83 size_t size;
84} eth_frame_t;
85
86/** ARP opcode */
87typedef enum {
88 /** Request */
89 aop_request,
90 /** Reply */
91 aop_reply
92} arp_opcode_t;
93
94/** ARP packet (for 48-bit MAC addresses and IPv4)
95 *
96 * Internal representation
97 */
98typedef struct {
99 /** Opcode */
100 arp_opcode_t opcode;
101 /** Sender hardware address */
102 mac48_addr_t sender_hw_addr;
103 /** Sender protocol address */
104 iplink_srv_addr_t sender_proto_addr;
105 /** Target hardware address */
106 mac48_addr_t target_hw_addr;
107 /** Target protocol address */
108 iplink_srv_addr_t target_proto_addr;
109} arp_eth_packet_t;
110
111extern int ethip_iplink_init(ethip_nic_t *);
112extern int ethip_received(iplink_srv_t *, void *, size_t);
113
114#endif
115
116/** @}
117 */
Note: See TracBrowser for help on using the repository browser.