Changes in uspace/srv/net/udp/service.c [e1abc964:fafb8e5] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/service.c
re1abc964 rfafb8e5 46 46 47 47 #include "assoc.h" 48 #include "cassoc.h"49 48 #include "msg.h" 50 49 #include "service.h" … … 56 55 #define MAX_MSG_SIZE DATA_XFER_LIMIT 57 56 58 static void udp_ recv_msg_cassoc(void *, inet_ep2_t *, udp_msg_t *);57 static void udp_cassoc_recv_msg(void *, inet_ep2_t *, udp_msg_t *); 59 58 60 59 /** Callbacks to tie us to association layer */ 61 60 static udp_assoc_cb_t udp_cassoc_cb = { 62 .recv_msg = udp_ recv_msg_cassoc61 .recv_msg = udp_cassoc_recv_msg 63 62 }; 63 64 /** Add message to client receive queue. 65 * 66 * @param cassoc Client association 67 * @param epp Endpoint pair on which message was received 68 * @param msg Message 69 * 70 * @return EOK on success, ENOMEM if out of memory 71 */ 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 } 64 92 65 93 /** Send 'data' event to client. … … 80 108 } 81 109 110 /** Create client association. 111 * 112 * This effectively adds an association into a client's namespace. 113 * 114 * @param client Client 115 * @param assoc Association 116 * @param rcassoc Place to store pointer to new client association 117 * 118 * @return EOK on soccess, ENOMEM if out of memory 119 */ 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 association 149 */ 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 Client 159 * @param id Client association ID 160 * @param rcassoc Place to store pointer to client association 161 * 162 * @return EOK on success, ENOENT if no client association with the given ID 163 * 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 82 178 /** Message received on client association. 83 179 * … … 88 184 * @param msg Message 89 185 */ 90 static void udp_ recv_msg_cassoc(void *arg, inet_ep2_t *epp, udp_msg_t *msg)186 static void udp_cassoc_recv_msg(void *arg, inet_ep2_t *epp, udp_msg_t *msg) 91 187 { 92 188 udp_cassoc_t *cassoc = (udp_cassoc_t *) arg;
Note:
See TracChangeset
for help on using the changeset viewer.