Changeset ceba4bed in mainline
- Timestamp:
- 2012-02-06T17:38:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e767dbf
- Parents:
- bc38578
- Location:
- uspace
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink.c
rbc38578 rceba4bed 88 88 89 89 ipc_call_t answer; 90 aid_t req = async_send_2(exch, IPLINK_SEND, sdu-> src.ipv4,91 sdu-> dest.ipv4, &answer);90 aid_t req = async_send_2(exch, IPLINK_SEND, sdu->lsrc.ipv4, 91 sdu->ldest.ipv4, &answer); 92 92 int rc = async_data_write_start(exch, sdu->data, sdu->size); 93 93 async_exchange_end(exch); … … 127 127 iplink_sdu_t sdu; 128 128 129 sdu. src.ipv4 = IPC_GET_ARG1(*call);130 sdu. dest.ipv4 = IPC_GET_ARG2(*call);129 sdu.lsrc.ipv4 = IPC_GET_ARG1(*call); 130 sdu.ldest.ipv4 = IPC_GET_ARG2(*call); 131 131 132 132 rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size); -
uspace/lib/c/generic/iplink_srv.c
rbc38578 rceba4bed 57 57 int rc; 58 58 59 sdu. src.ipv4 = IPC_GET_ARG1(*call);60 sdu. dest.ipv4 = IPC_GET_ARG2(*call);59 sdu.lsrc.ipv4 = IPC_GET_ARG1(*call); 60 sdu.ldest.ipv4 = IPC_GET_ARG2(*call); 61 61 62 62 rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size); … … 122 122 123 123 ipc_call_t answer; 124 aid_t req = async_send_2(exch, IPLINK_EV_RECV, sdu-> src.ipv4,125 sdu-> dest.ipv4, &answer);124 aid_t req = async_send_2(exch, IPLINK_EV_RECV, sdu->lsrc.ipv4, 125 sdu->ldest.ipv4, &answer); 126 126 int rc = async_data_write_start(exch, sdu->data, sdu->size); 127 127 async_exchange_end(exch); -
uspace/lib/c/include/inet/iplink.h
rbc38578 rceba4bed 52 52 /** IP link Service Data Unit */ 53 53 typedef struct { 54 /** Source address */55 iplink_addr_t src;56 /** Destination address */57 iplink_addr_t dest;54 /** Local source address */ 55 iplink_addr_t lsrc; 56 /** Local destination address */ 57 iplink_addr_t ldest; 58 58 /** Serialized IP packet */ 59 59 void *data; -
uspace/lib/c/include/inet/iplink_srv.h
rbc38578 rceba4bed 57 57 /** IP link Service Data Unit */ 58 58 typedef struct { 59 /** Source address */60 iplink_srv_addr_t src;61 /** Destination address */62 iplink_srv_addr_t dest;59 /** Local source address */ 60 iplink_srv_addr_t lsrc; 61 /** Local destination address */ 62 iplink_srv_addr_t ldest; 63 63 /** Serialized IP packet */ 64 64 void *data; -
uspace/srv/inet/Makefile
rbc38578 rceba4bed 31 31 32 32 SOURCES = \ 33 addrobj.c \ 33 34 inet.c \ 34 inet_link.c 35 inet_link.c \ 36 pdu.c 35 37 36 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/inet/inet.c
rbc38578 rceba4bed 47 47 #include <sys/types.h> 48 48 49 #include "addrobj.h" 49 50 #include "inet.h" 50 51 #include "inet_link.h" … … 85 86 } 86 87 87 static void inet_callback_create (inet_client_t *client, ipc_callid_t callid,88 ipc_call_t *call) 89 { 90 log_msg(LVL_DEBUG, "inet_callback_create ()");88 static void inet_callback_create_srv(inet_client_t *client, ipc_callid_t callid, 89 ipc_call_t *call) 90 { 91 log_msg(LVL_DEBUG, "inet_callback_create_srv()"); 91 92 92 93 async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE); … … 100 101 } 101 102 102 static void inet_get_srcaddr(inet_client_t *client, ipc_callid_t callid, 103 ipc_call_t *call) 104 { 105 log_msg(LVL_DEBUG, "inet_get_srcaddr()"); 103 static int inet_send(inet_client_t *client, inet_dgram_t *dgram, 104 uint8_t ttl, int df) 105 { 106 inet_addrobj_t *addr; 107 108 addr = inet_addrobj_find(&dgram->dest); 109 if (addr != NULL) { 110 /* Destination is directly accessible */ 111 return inet_addrobj_send_dgram(addr, dgram, ttl, df); 112 } 113 114 /* TODO: Gateways */ 115 log_msg(LVL_DEBUG, "inet_send: No route to destination."); 116 return ENOENT; 117 } 118 119 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t callid, 120 ipc_call_t *call) 121 { 122 log_msg(LVL_DEBUG, "inet_get_srcaddr_srv()"); 106 123 107 124 async_answer_0(callid, ENOTSUP); 108 125 } 109 126 110 static void inet_send (inet_client_t *client, ipc_callid_t callid,127 static void inet_send_srv(inet_client_t *client, ipc_callid_t callid, 111 128 ipc_call_t *call) 112 129 { … … 116 133 int rc; 117 134 118 log_msg(LVL_DEBUG, "inet_send ()");135 log_msg(LVL_DEBUG, "inet_send_srv()"); 119 136 120 137 dgram.src.ipv4 = IPC_GET_ARG1(*call); … … 124 141 df = IPC_GET_ARG5(*call); 125 142 126 (void)ttl;127 (void)df;128 129 143 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size); 130 144 if (rc != EOK) { … … 133 147 } 134 148 149 rc = inet_send(client, &dgram, ttl, df); 150 135 151 free(dgram.data); 136 async_answer_0(callid, ENOTSUP);137 } 138 139 static void inet_set_proto (inet_client_t *client, ipc_callid_t callid,152 async_answer_0(callid, rc); 153 } 154 155 static void inet_set_proto_srv(inet_client_t *client, ipc_callid_t callid, 140 156 ipc_call_t *call) 141 157 { … … 143 159 144 160 proto = IPC_GET_ARG1(*call); 145 log_msg(LVL_DEBUG, "inet_set_proto (%lu)", (unsigned long) proto);161 log_msg(LVL_DEBUG, "inet_set_proto_srv(%lu)", (unsigned long) proto); 146 162 147 163 if (proto > UINT8_MAX) { … … 197 213 switch (method) { 198 214 case INET_CALLBACK_CREATE: 199 inet_callback_create (&client, callid, &call);215 inet_callback_create_srv(&client, callid, &call); 200 216 break; 201 217 case INET_GET_SRCADDR: 202 inet_get_srcaddr (&client, callid, &call);218 inet_get_srcaddr_srv(&client, callid, &call); 203 219 break; 204 220 case INET_SEND: 205 inet_send (&client, callid, &call);221 inet_send_srv(&client, callid, &call); 206 222 break; 207 223 case INET_SET_PROTO: 208 inet_set_proto (&client, callid, &call);224 inet_set_proto_srv(&client, callid, &call); 209 225 break; 210 226 default: -
uspace/srv/inet/inet.h
rbc38578 rceba4bed 39 39 40 40 #include <adt/list.h> 41 #include <inet/iplink.h> 42 #include <ipc/loc.h> 41 43 #include <sys/types.h> 42 44 #include <async.h> … … 49 51 } inet_client_t; 50 52 53 /** Host address */ 51 54 typedef struct { 52 55 uint32_t ipv4; 53 56 } inet_addr_t; 57 58 /** Network address */ 59 typedef struct { 60 /** Address */ 61 uint32_t ipv4; 62 /** Number of valid bits in @c ipv4 */ 63 int bits; 64 } inet_naddr_t; 54 65 55 66 typedef struct { … … 61 72 } inet_dgram_t; 62 73 74 typedef struct { 75 link_t link_list; 76 service_id_t svc_id; 77 char *svc_name; 78 async_sess_t *sess; 79 iplink_t *iplink; 80 } inet_link_t; 81 82 typedef struct { 83 link_t addr_list; 84 inet_naddr_t naddr; 85 inet_link_t *ilink; 86 } inet_addrobj_t; 87 63 88 extern int inet_ev_recv(inet_client_t *, inet_dgram_t *); 64 89 -
uspace/srv/inet/inet_link.c
rbc38578 rceba4bed 43 43 #include <stdlib.h> 44 44 45 #include "addrobj.h" 46 #include "inet.h" 45 47 #include "inet_link.h" 48 #include "pdu.h" 46 49 47 50 static int inet_link_open(service_id_t sid); 48 51 static int inet_iplink_recv(iplink_t *ilink, iplink_sdu_t *sdu); 49 50 typedef struct {51 link_t link_list;52 service_id_t svc_id;53 char *svc_name;54 async_sess_t *sess;55 iplink_t *iplink;56 } inet_link_t;57 52 58 53 static iplink_ev_ops_t inet_iplink_ev_ops = { … … 172 167 list_append(&ilink->link_list, &inet_link_list); 173 168 169 inet_addrobj_t *addr; 170 171 /* XXX For testing: set static IP address 192.168.0.4/24 */ 172 addr = inet_addrobj_new(); 173 addr->naddr.ipv4 = (192 << 24) + (168 << 16) + (0 << 8) + 4; 174 addr->naddr.bits = 24; 175 addr->ilink = ilink; 176 inet_addrobj_add(addr); 177 174 178 return EOK; 175 179 … … 198 202 } 199 203 204 /** Send datagram over Internet link */ 205 int inet_link_send_dgram(inet_link_t *ilink, inet_addr_t *lsrc, 206 inet_addr_t *ldest, inet_dgram_t *dgram, uint8_t ttl, int df) 207 { 208 iplink_sdu_t sdu; 209 int rc; 210 211 sdu.lsrc.ipv4 = lsrc->ipv4; 212 sdu.ldest.ipv4 = ldest->ipv4; 213 rc = inet_pdu_encode(dgram, &sdu.data, &sdu.size); 214 if (rc != EOK) 215 return rc; 216 217 rc = iplink_send(ilink->iplink, &sdu); 218 free(sdu.data); 219 220 return rc; 221 } 222 223 200 224 /** @} 201 225 */ -
uspace/srv/inet/inet_link.h
rbc38578 rceba4bed 38 38 #define INET_LINK_H_ 39 39 40 #include "inet.h" 41 40 42 extern int inet_link_discovery_start(void); 43 extern int inet_link_send_dgram(inet_link_t *, inet_addr_t *, 44 inet_addr_t *, inet_dgram_t *, uint8_t, int); 41 45 42 46 #endif
Note:
See TracChangeset
for help on using the changeset viewer.