Changeset 1493811 in mainline
- Timestamp:
- 2012-02-11T19:11:08Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4f64a523
- Parents:
- e767dbf
- Location:
- uspace/srv/ethip
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ethip/Makefile
re767dbf r1493811 32 32 SOURCES = \ 33 33 ethip.c \ 34 ethip_nic.c 34 ethip_nic.c \ 35 pdu.c 35 36 36 37 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/ethip/ethip.c
re767dbf r1493811 27 27 */ 28 28 29 /** @addtogroup inet29 /** @addtogroup ethip 30 30 * @{ 31 31 */ … … 33 33 * @file 34 34 * @brief IP link provider for Ethernet 35 * 36 * Based on the IETF RFC 894 standard. 35 37 */ 36 38 … … 45 47 #include "ethip.h" 46 48 #include "ethip_nic.h" 49 #include "pdu.h" 50 #include "std.h" 47 51 48 52 #define NAME "eth" … … 158 162 static int ethip_send(iplink_conn_t *conn, iplink_srv_sdu_t *sdu) 159 163 { 164 ethip_nic_t *nic = (ethip_nic_t *)conn->srv->arg; 165 eth_frame_t frame; 166 void *data; 167 size_t size; 168 int rc; 169 160 170 log_msg(LVL_DEBUG, "ethip_send()"); 161 return EOK; 171 172 frame.dest.addr = 0xdeeedeeedeee; 173 frame.src.addr = 0xaafeedfaceee; 174 frame.etype_len = ETYPE_IP; 175 frame.data = sdu->data; 176 frame.size = sdu->size; 177 178 rc = eth_pdu_encode(&frame, &data, &size); 179 if (rc != EOK) 180 return rc; 181 182 rc = ethip_nic_send(nic, data, size); 183 free(data); 184 185 return rc; 186 } 187 188 int ethip_received(iplink_srv_t *srv, void *data, size_t size) 189 { 190 eth_frame_t frame; 191 iplink_srv_sdu_t sdu; 192 int rc; 193 194 rc = eth_pdu_decode(data, size, &frame); 195 if (rc != EOK) 196 return rc; 197 198 sdu.data = frame.data; 199 sdu.size = frame.size; 200 (void) sdu; 201 //rc = iplink_ev_recv(conn, &sdu); 202 203 free(frame.data); 204 return rc; 162 205 } 163 206 -
uspace/srv/ethip/ethip.h
re767dbf r1493811 27 27 */ 28 28 29 /** @addtogroup inet29 /** @addtogroup ethip 30 30 * @{ 31 31 */ … … 37 37 #ifndef ETHIP_H_ 38 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> 39 45 40 46 typedef struct ethip_nic { … … 48 54 } ethip_nic_t; 49 55 56 /** IEEE MAC-48 identifier */ 57 typedef struct { 58 /** MAC Address (in lowest 48 bits) */ 59 uint64_t addr; 60 } mac48_addr_t; 61 62 /** Ethernet frame */ 63 typedef struct { 64 /** Destination Address */ 65 mac48_addr_t dest; 66 /** Source Address */ 67 mac48_addr_t src; 68 /** Ethertype or Length */ 69 uint16_t etype_len; 70 /** Payload */ 71 void *data; 72 /** Payload size */ 73 size_t size; 74 } eth_frame_t; 75 50 76 extern int ethip_iplink_init(ethip_nic_t *); 77 extern int ethip_received(iplink_srv_t *, void *, size_t); 78 51 79 52 80 #endif -
uspace/srv/ethip/ethip_nic.c
re767dbf r1493811 27 27 */ 28 28 29 /** @addtogroup inet29 /** @addtogroup ethip 30 30 * @{ 31 31 */ … … 201 201 ipc_call_t *call) 202 202 { 203 int rc; 204 void *data; 205 size_t size; 206 203 207 log_msg(LVL_DEBUG, "ethip_nic_received()"); 204 async_answer_0(callid, ENOTSUP); 208 209 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 210 if (rc != EOK) { 211 log_msg(LVL_DEBUG, "data_write_accept() failed"); 212 return; 213 } 214 215 rc = ethip_received(&nic->iplink, data, size); 216 free(data); 217 218 async_answer_0(callid, rc); 205 219 } 206 220 … … 277 291 } 278 292 293 int ethip_nic_send(ethip_nic_t *nic, void *data, size_t size) 294 { 295 return nic_send_frame(nic->sess, data, size); 296 } 297 279 298 /** @} 280 299 */ -
uspace/srv/ethip/ethip_nic.h
re767dbf r1493811 27 27 */ 28 28 29 /** @addtogroup inet29 /** @addtogroup ethip 30 30 * @{ 31 31 */ … … 42 42 extern int ethip_nic_discovery_start(void); 43 43 extern ethip_nic_t *ethip_nic_find_by_iplink_sid(service_id_t); 44 extern int ethip_nic_send(ethip_nic_t *, void *, size_t); 45 44 46 45 47 #endif
Note:
See TracChangeset
for help on using the changeset viewer.