Changeset e1abc964 in mainline
- Timestamp:
- 2019-11-13T13:14:16Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b9a853
- Parents:
- 453c5ce
- git-author:
- Jiri Svoboda <jiri@…> (2019-11-12 19:13:52)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-11-13 13:14:16)
- Location:
- uspace/srv/net/udp
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/meson.build
r453c5ce re1abc964 31 31 _common_src = files( 32 32 'assoc.c', 33 'cassoc.c', 33 34 'msg.c', 34 35 'pdu.c', -
uspace/srv/net/udp/service.c
r453c5ce re1abc964 46 46 47 47 #include "assoc.h" 48 #include "cassoc.h" 48 49 #include "msg.h" 49 50 #include "service.h" … … 55 56 #define MAX_MSG_SIZE DATA_XFER_LIMIT 56 57 57 static void udp_ cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *);58 static void udp_recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *); 58 59 59 60 /** Callbacks to tie us to association layer */ 60 61 static udp_assoc_cb_t udp_cassoc_cb = { 61 .recv_msg = udp_ cassoc_recv_msg62 .recv_msg = udp_recv_msg_cassoc 62 63 }; 63 64 /** Add message to client receive queue.65 *66 * @param cassoc Client association67 * @param epp Endpoint pair on which message was received68 * @param msg Message69 *70 * @return EOK on success, ENOMEM if out of memory71 */72 static errno_t udp_cassoc_queue_msg(udp_cassoc_t *cassoc, inet_ep2_t *epp,73 udp_msg_t *msg)74 {75 udp_crcv_queue_entry_t *rqe;76 77 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_cassoc_queue_msg(%p, %p, %p)",78 cassoc, epp, msg);79 80 rqe = calloc(1, sizeof(udp_crcv_queue_entry_t));81 if (rqe == NULL)82 return ENOMEM;83 84 link_initialize(&rqe->link);85 rqe->epp = *epp;86 rqe->msg = msg;87 rqe->cassoc = cassoc;88 89 list_append(&rqe->link, &cassoc->client->crcv_queue);90 return EOK;91 }92 64 93 65 /** Send 'data' event to client. … … 108 80 } 109 81 110 /** Create client association.111 *112 * This effectively adds an association into a client's namespace.113 *114 * @param client Client115 * @param assoc Association116 * @param rcassoc Place to store pointer to new client association117 *118 * @return EOK on soccess, ENOMEM if out of memory119 */120 static errno_t udp_cassoc_create(udp_client_t *client, udp_assoc_t *assoc,121 udp_cassoc_t **rcassoc)122 {123 udp_cassoc_t *cassoc;124 sysarg_t id;125 126 cassoc = calloc(1, sizeof(udp_cassoc_t));127 if (cassoc == NULL)128 return ENOMEM;129 130 /* Allocate new ID */131 id = 0;132 list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {133 if (cassoc->id >= id)134 id = cassoc->id + 1;135 }136 137 cassoc->id = id;138 cassoc->client = client;139 cassoc->assoc = assoc;140 141 list_append(&cassoc->lclient, &client->cassoc);142 *rcassoc = cassoc;143 return EOK;144 }145 146 /** Destroy client association.147 *148 * @param cassoc Client association149 */150 static void udp_cassoc_destroy(udp_cassoc_t *cassoc)151 {152 list_remove(&cassoc->lclient);153 free(cassoc);154 }155 156 /** Get client association by ID.157 *158 * @param client Client159 * @param id Client association ID160 * @param rcassoc Place to store pointer to client association161 *162 * @return EOK on success, ENOENT if no client association with the given ID163 * is found.164 */165 static errno_t udp_cassoc_get(udp_client_t *client, sysarg_t id,166 udp_cassoc_t **rcassoc)167 {168 list_foreach (client->cassoc, lclient, udp_cassoc_t, cassoc) {169 if (cassoc->id == id) {170 *rcassoc = cassoc;171 return EOK;172 }173 }174 175 return ENOENT;176 }177 178 82 /** Message received on client association. 179 83 * … … 184 88 * @param msg Message 185 89 */ 186 static void udp_ cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg)90 static void udp_recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg) 187 91 { 188 92 udp_cassoc_t *cassoc = (udp_cassoc_t *) arg;
Note:
See TracChangeset
for help on using the changeset viewer.