Changeset ecff3d9 in mainline
- Timestamp:
- 2012-02-01T22:06:05Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 59157eb
- Parents:
- c76e926
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet.c
rc76e926 recff3d9 75 75 { 76 76 service_id_t inet_svc; 77 int rc; 77 78 78 79 assert(inet_sess == NULL); … … 80 81 assert(inet_protocol == 0); 81 82 82 inet_svc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc,83 rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc, 83 84 IPC_FLAG_BLOCKING); 85 if (rc != EOK) 86 return ENOENT; 87 84 88 inet_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc, 85 89 IPC_FLAG_BLOCKING); … … 107 111 int inet_send(inet_dgram_t *dgram, uint8_t ttl, inet_df_t df) 108 112 { 109 return ENOTSUP; 113 async_exch_t *exch = async_exchange_begin(inet_sess); 114 115 ipc_call_t answer; 116 aid_t req = async_send_5(exch, INET_SEND, dgram->src.ipv4, 117 dgram->dest.ipv4, dgram->tos, ttl, df, &answer); 118 int rc = async_data_write_start(exch, dgram->data, dgram->size); 119 async_exchange_end(exch); 120 121 if (rc != EOK) { 122 async_wait_for(req, NULL); 123 return rc; 124 } 125 126 sysarg_t retval; 127 async_wait_for(req, &retval); 128 if (retval != EOK) 129 return retval; 130 131 return EOK; 110 132 } 111 133 112 134 int inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local) 113 135 { 114 return ENOTSUP; 136 sysarg_t local_addr; 137 async_exch_t *exch = async_exchange_begin(inet_sess); 138 139 int rc = async_req_1_1(exch, INET_GET_SRCADDR, remote->ipv4, 140 &local_addr); 141 async_exchange_end(exch); 142 143 if (rc != EOK) 144 return rc; 145 146 local->ipv4 = local_addr; 147 return EOK; 115 148 } 116 149 -
uspace/lib/c/include/ipc/inet.h
rc76e926 recff3d9 40 40 typedef enum { 41 41 INET_CALLBACK_CREATE = IPC_FIRST_USER_METHOD, 42 INET_GET_SRCADDR, 42 43 INET_SEND, 43 44 INET_SET_PROTO -
uspace/srv/inet/inet.c
rc76e926 recff3d9 44 44 #include <loc.h> 45 45 #include <stdio.h> 46 #include <stdlib.h> 46 47 #include <sys/types.h> 47 48 … … 99 100 } 100 101 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()"); 106 107 async_answer_0(callid, ENOTSUP); 108 } 109 101 110 static void inet_send(inet_client_t *client, ipc_callid_t callid, 102 111 ipc_call_t *call) 103 112 { 113 uint32_t src_ipv4; 114 uint32_t dest_ipv4; 115 uint8_t tos; 116 uint8_t ttl; 117 int df; 118 void *data; 119 size_t size; 120 int rc; 121 104 122 log_msg(LVL_DEBUG, "inet_send()"); 123 124 src_ipv4 = IPC_GET_ARG1(*call); 125 dest_ipv4 = IPC_GET_ARG2(*call); 126 tos = IPC_GET_ARG3(*call); 127 ttl = IPC_GET_ARG4(*call); 128 df = IPC_GET_ARG5(*call); 129 130 (void)src_ipv4; 131 (void)dest_ipv4; 132 (void)tos; 133 (void)ttl; 134 (void)df; 135 136 rc = async_data_write_accept(&data, false, 0, 0, 0, &size); 137 if (rc != EOK) { 138 async_answer_0(callid, rc); 139 return; 140 } 141 142 free(data); 105 143 async_answer_0(callid, ENOTSUP); 106 144 } … … 168 206 inet_callback_create(&client, callid, &call); 169 207 break; 208 case INET_GET_SRCADDR: 209 inet_get_srcaddr(&client, callid, &call); 210 break; 170 211 case INET_SEND: 171 212 inet_send(&client, callid, &call); … … 197 238 return 1; 198 239 240 printf(NAME ": Accepting connections.\n"); 199 241 task_retval(0); 200 242 async_manager(); -
uspace/srv/tcp/tcp.c
rc76e926 recff3d9 186 186 187 187 rc = inet_init(42, &tcp_inet_ev_ops); 188 if (rc != EOK) 188 if (rc != EOK) { 189 log_msg(LVL_ERROR, "Failed connecting to internet service."); 189 190 return ENOENT; 191 } 190 192 191 193 rc = tcp_sock_init(); 192 if (rc != EOK) 194 if (rc != EOK) { 195 log_msg(LVL_ERROR, "Failed initializing socket service."); 193 196 return ENOENT; 197 } 194 198 195 199 return EOK; … … 208 212 } 209 213 210 tcp_init(); 214 rc = tcp_init(); 215 if (rc != EOK) 216 return 1; 217 218 printf(NAME ": Accepting connections.\n"); 211 219 task_retval(0); 212 220 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.