Changeset 4f64a523 in mainline for uspace/lib/c
- Timestamp:
- 2012-02-12T19:36:32Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- df15e5f
- Parents:
- 1493811
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/iplink_srv.c
r1493811 r4f64a523 41 41 #include <inet/iplink_srv.h> 42 42 43 static void iplink_get_mtu_srv(iplink_ conn_t *conn, ipc_callid_t callid,43 static void iplink_get_mtu_srv(iplink_srv_t *srv, ipc_callid_t callid, 44 44 ipc_call_t *call) 45 45 { … … 47 47 size_t mtu; 48 48 49 rc = conn->srv->ops->get_mtu(conn, &mtu);49 rc = srv->ops->get_mtu(srv, &mtu); 50 50 async_answer_1(callid, rc, mtu); 51 51 } 52 52 53 static void iplink_send_srv(iplink_ conn_t *conn, ipc_callid_t callid,53 static void iplink_send_srv(iplink_srv_t *srv, ipc_callid_t callid, 54 54 ipc_call_t *call) 55 55 { … … 66 66 } 67 67 68 rc = conn->srv->ops->send(conn, &sdu);68 rc = srv->ops->send(srv, &sdu); 69 69 free(sdu.data); 70 70 async_answer_0(callid, rc); 71 } 72 73 void iplink_srv_init(iplink_srv_t *srv) 74 { 75 fibril_mutex_initialize(&srv->lock); 76 srv->connected = false; 77 srv->ops = NULL; 78 srv->arg = NULL; 79 srv->client_sess = NULL; 71 80 } 72 81 … … 74 83 { 75 84 iplink_srv_t *srv = (iplink_srv_t *)arg; 76 iplink_conn_t conn;77 85 int rc; 86 87 fibril_mutex_lock(&srv->lock); 88 if (srv->connected) { 89 fibril_mutex_unlock(&srv->lock); 90 async_answer_0(iid, EBUSY); 91 return EBUSY; 92 } 93 94 srv->connected = true; 95 fibril_mutex_unlock(&srv->lock); 78 96 79 97 /* Accept the connection */ … … 84 102 return ENOMEM; 85 103 86 conn.srv = srv; 87 conn.client_sess = sess; 104 srv->client_sess = sess; 88 105 89 rc = srv->ops->open( &conn);106 rc = srv->ops->open(srv); 90 107 if (rc != EOK) 91 108 return rc; … … 104 121 switch (method) { 105 122 case IPLINK_GET_MTU: 106 iplink_get_mtu_srv( &conn, callid, &call);123 iplink_get_mtu_srv(srv, callid, &call); 107 124 break; 108 125 case IPLINK_SEND: 109 iplink_send_srv( &conn, callid, &call);126 iplink_send_srv(srv, callid, &call); 110 127 break; 111 128 default: … … 114 131 } 115 132 116 return srv->ops->close( &conn);133 return srv->ops->close(srv); 117 134 } 118 135 119 int iplink_ev_recv(iplink_ conn_t *conn, iplink_srv_sdu_t *sdu)136 int iplink_ev_recv(iplink_srv_t *srv, iplink_srv_sdu_t *sdu) 120 137 { 121 async_exch_t *exch = async_exchange_begin(conn->client_sess); 138 if (srv->client_sess == NULL) 139 return EIO; 140 141 async_exch_t *exch = async_exchange_begin(srv->client_sess); 122 142 123 143 ipc_call_t answer; -
uspace/lib/c/include/inet/iplink_srv.h
r1493811 r4f64a523 37 37 38 38 #include <async.h> 39 #include <fibril_synch.h> 40 #include <bool.h> 39 41 #include <sys/types.h> 40 42 … … 42 44 43 45 typedef struct { 46 fibril_mutex_t lock; 47 bool connected; 44 48 struct iplink_ops *ops; 45 49 void *arg; 50 async_sess_t *client_sess; 46 51 } iplink_srv_t; 47 48 typedef struct {49 iplink_srv_t *srv;50 async_sess_t *client_sess;51 } iplink_conn_t;52 52 53 53 typedef struct { … … 68 68 69 69 typedef struct iplink_ops { 70 int (*open)(iplink_ conn_t *);71 int (*close)(iplink_ conn_t *);72 int (*send)(iplink_ conn_t *, iplink_srv_sdu_t *);73 int (*get_mtu)(iplink_ conn_t *, size_t *);70 int (*open)(iplink_srv_t *); 71 int (*close)(iplink_srv_t *); 72 int (*send)(iplink_srv_t *, iplink_srv_sdu_t *); 73 int (*get_mtu)(iplink_srv_t *, size_t *); 74 74 } iplink_ops_t; 75 75 76 extern void iplink_srv_init(iplink_srv_t *); 77 76 78 extern int iplink_conn(ipc_callid_t, ipc_call_t *, void *); 77 extern int iplink_ev_recv(iplink_ conn_t *, iplink_srv_sdu_t *);79 extern int iplink_ev_recv(iplink_srv_t *, iplink_srv_sdu_t *); 78 80 79 81 #endif
Note:
See TracChangeset
for help on using the changeset viewer.