LLC: tcpfying the beast

. s/mac_indicate/llc_rcv/g
. s/llc_sap_send_ev/llc_sap_state_process/g
. s/llc_station_send_ev/llc_station_state_process/g
. s/llc_conn_send_ev/llc_conn_state_process/g
. fix some comments wrt current behaviour
. s/llc_find_sock/llc_lookup_established/g
. llc_sock_alloc now receives the protocol family as a
  parameter, will be used by llc_lookup_listener to
  properly handle multiple upper layer protocols
. s/inline/__inline__/g
parent b0d8626b
...@@ -80,7 +80,7 @@ struct llc_opt { ...@@ -80,7 +80,7 @@ struct llc_opt {
struct llc_conn_state_ev; struct llc_conn_state_ev;
extern struct sock *__llc_sock_alloc(void); extern struct sock *__llc_sock_alloc(int family);
extern void __llc_sock_free(struct sock *sk, u8 free); extern void __llc_sock_free(struct sock *sk, u8 free);
#ifdef DEBUG_LLC_CONN_ALLOC #ifdef DEBUG_LLC_CONN_ALLOC
...@@ -88,8 +88,8 @@ extern void __llc_sock_free(struct sock *sk, u8 free); ...@@ -88,8 +88,8 @@ extern void __llc_sock_free(struct sock *sk, u8 free);
__builtin_return_address(0), \ __builtin_return_address(0), \
__builtin_return_address(1), \ __builtin_return_address(1), \
__builtin_return_address(2)); __builtin_return_address(2));
#define llc_sock_alloc() ({ \ #define llc_sock_alloc(family) ({ \
struct sock *__sk = __llc_sock_alloc(); \ struct sock *__sk = __llc_sock_alloc(family); \
if (__sk) { \ if (__sk) { \
llc_sk(__sk)->f_alloc = __FUNCTION__; \ llc_sk(__sk)->f_alloc = __FUNCTION__; \
llc_sk(__sk)->l_alloc = __LINE__; \ llc_sk(__sk)->l_alloc = __LINE__; \
...@@ -126,7 +126,7 @@ extern void __llc_sock_free(struct sock *sk, u8 free); ...@@ -126,7 +126,7 @@ extern void __llc_sock_free(struct sock *sk, u8 free);
return __ret; } \ return __ret; } \
} }
#else /* DEBUG_LLC_CONN_ALLOC */ #else /* DEBUG_LLC_CONN_ALLOC */
#define llc_sock_alloc() __llc_sock_alloc() #define llc_sock_alloc(family) __llc_sock_alloc(family)
#define llc_sock_free(__sk) __llc_sock_free(__sk, 1) #define llc_sock_free(__sk) __llc_sock_free(__sk, 1)
#define llc_sock_assert(__sk) #define llc_sock_assert(__sk)
#define llc_sock_assert_ret(__sk) #define llc_sock_assert_ret(__sk)
...@@ -136,7 +136,7 @@ extern void llc_sock_reset(struct sock *sk); ...@@ -136,7 +136,7 @@ extern void llc_sock_reset(struct sock *sk);
extern int llc_sock_init(struct sock *sk); extern int llc_sock_init(struct sock *sk);
/* Access to a connection */ /* Access to a connection */
extern int llc_conn_send_ev(struct sock *sk, struct sk_buff *skb); extern int llc_conn_state_process(struct sock *sk, struct sk_buff *skb);
extern void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb); extern void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb);
extern void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb); extern void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb);
extern void llc_conn_free_ev(struct sk_buff *skb); extern void llc_conn_free_ev(struct sk_buff *skb);
...@@ -146,8 +146,9 @@ extern void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr, ...@@ -146,8 +146,9 @@ extern void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr,
u8 first_f_bit); u8 first_f_bit);
extern int llc_conn_remove_acked_pdus(struct sock *conn, u8 nr, extern int llc_conn_remove_acked_pdus(struct sock *conn, u8 nr,
u16 *how_many_unacked); u16 *how_many_unacked);
extern struct sock *llc_find_sock(struct llc_sap *sap, struct llc_addr *daddr, extern struct sock *llc_lookup_established(struct llc_sap *sap,
struct llc_addr *laddr); struct llc_addr *daddr,
struct llc_addr *laddr);
extern u8 llc_data_accept_state(u8 state); extern u8 llc_data_accept_state(u8 state);
extern void llc_build_offset_table(void); extern void llc_build_offset_table(void);
#endif /* LLC_CONN_H */ #endif /* LLC_CONN_H */
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
*/ */
/* Defines MAC-layer interface to LLC layer */ /* Defines MAC-layer interface to LLC layer */
extern int mac_send_pdu(struct sk_buff *skb); extern int mac_send_pdu(struct sk_buff *skb);
extern int mac_indicate(struct sk_buff *skb, struct net_device *dev, extern int llc_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt); struct packet_type *pt);
extern struct net_device *mac_dev_peer(struct net_device *current_dev, extern struct net_device *mac_dev_peer(struct net_device *current_dev,
int type, u8 *mac); int type, u8 *mac);
extern int llc_pdu_router(struct llc_sap *sap, struct sock *sk, extern int llc_pdu_router(struct llc_sap *sap, struct sock *sk,
......
...@@ -61,8 +61,8 @@ extern void llc_sap_save(struct llc_sap *sap); ...@@ -61,8 +61,8 @@ extern void llc_sap_save(struct llc_sap *sap);
extern void llc_free_sap(struct llc_sap *sap); extern void llc_free_sap(struct llc_sap *sap);
extern struct llc_sap *llc_sap_find(u8 lsap); extern struct llc_sap *llc_sap_find(u8 lsap);
extern struct llc_station *llc_station_get(void); extern struct llc_station *llc_station_get(void);
extern void llc_station_send_ev(struct llc_station *station, extern void llc_station_state_process(struct llc_station *station,
struct sk_buff *skb); struct sk_buff *skb);
extern void llc_station_send_pdu(struct llc_station *station, extern void llc_station_send_pdu(struct llc_station *station,
struct sk_buff *skb); struct sk_buff *skb);
extern struct sk_buff *llc_alloc_frame(void); extern struct sk_buff *llc_alloc_frame(void);
......
...@@ -49,7 +49,7 @@ struct llc_sap_state_ev; ...@@ -49,7 +49,7 @@ struct llc_sap_state_ev;
extern void llc_sap_assign_sock(struct llc_sap *sap, struct sock *sk); extern void llc_sap_assign_sock(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk); extern void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_send_ev(struct llc_sap *sap, struct sk_buff *skb); extern void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb); extern void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb);
#endif /* LLC_SAP_H */ #endif /* LLC_SAP_H */
...@@ -142,6 +142,6 @@ static void llc_station_ack_tmr_callback(unsigned long timeout_data) ...@@ -142,6 +142,6 @@ static void llc_station_ack_tmr_callback(unsigned long timeout_data)
ev->type = LLC_STATION_EV_TYPE_ACK_TMR; ev->type = LLC_STATION_EV_TYPE_ACK_TMR;
ev->data.tmr.timer_specific = NULL; ev->data.tmr.timer_specific = NULL;
llc_station_send_ev(station, skb); llc_station_state_process(station, skb);
} }
} }
...@@ -1589,8 +1589,8 @@ u8 llc_circular_between(u8 a, u8 b, u8 c) ...@@ -1589,8 +1589,8 @@ u8 llc_circular_between(u8 a, u8 b, u8 c)
* This function is called from timer callback functions. When connection * This function is called from timer callback functions. When connection
* is busy (during sending a data frame) timer expiration event must be * is busy (during sending a data frame) timer expiration event must be
* queued. Otherwise this event can be sent to connection state machine. * queued. Otherwise this event can be sent to connection state machine.
* Queued events will process by process_rxframes_events function after * Queued events will process by llc_backlog_rcv function after sending
* sending data frame. Returns 0 for success, 1 otherwise. * data frame.
*/ */
static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb) static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
{ {
...@@ -1602,7 +1602,7 @@ static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb) ...@@ -1602,7 +1602,7 @@ static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
goto out; goto out;
} }
if (!sk->lock.users) if (!sk->lock.users)
llc_conn_send_ev(sk, skb); llc_conn_state_process(sk, skb);
else { else {
llc_set_backlog_type(skb, LLC_EVENT); llc_set_backlog_type(skb, LLC_EVENT);
sk_add_backlog(sk, skb); sk_add_backlog(sk, skb);
......
...@@ -39,7 +39,7 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk, ...@@ -39,7 +39,7 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk,
static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
/** /**
* llc_conn_send_event - sends event to connection state machine * llc_conn_state_process - sends event to connection state machine
* @sk: connection * @sk: connection
* @skb: occurred event * @skb: occurred event
* *
...@@ -48,7 +48,7 @@ static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; ...@@ -48,7 +48,7 @@ static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV];
* indicated or confirmed, if needed. Returns 0 for success, 1 for * indicated or confirmed, if needed. Returns 0 for success, 1 for
* failure. The socket lock has to be held before calling this function. * failure. The socket lock has to be held before calling this function.
*/ */
int llc_conn_send_ev(struct sock *sk, struct sk_buff *skb) int llc_conn_state_process(struct sock *sk, struct sk_buff *skb)
{ {
/* sending event to state machine */ /* sending event to state machine */
int rc = llc_conn_service(sk, skb); int rc = llc_conn_service(sk, skb);
...@@ -109,7 +109,7 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb) ...@@ -109,7 +109,7 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb)
* *
* Sends received data pdu to upper layer (by using indicate function). * Sends received data pdu to upper layer (by using indicate function).
* Prepares service parameters (prim and prim_data). calling indication * Prepares service parameters (prim and prim_data). calling indication
* function will be done in llc_conn_send_ev. * function will be done in llc_conn_state_process.
*/ */
void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb) void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb)
{ {
...@@ -127,7 +127,10 @@ void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb) ...@@ -127,7 +127,10 @@ void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb)
prim->prim = LLC_DATA_PRIM; prim->prim = LLC_DATA_PRIM;
prim->sap = sap; prim->sap = sap;
ev->flag = 1; ev->flag = 1;
/* saving prepd prim in event for future use in llc_conn_send_ev */ /*
* Saving prepd prim in event for future use in
* llc_conn_state_process
*/
ev->ind_prim = prim; ev->ind_prim = prim;
} }
...@@ -396,7 +399,7 @@ static int llc_exec_conn_trans_actions(struct sock *sk, ...@@ -396,7 +399,7 @@ static int llc_exec_conn_trans_actions(struct sock *sk,
} }
/** /**
* llc_find_sock - Finds connection in sap for the remote/local sap/mac * llc_lookup_established - Finds connection for the remote/local sap/mac
* @sap: SAP * @sap: SAP
* @daddr: address of remote LLC (MAC + SAP) * @daddr: address of remote LLC (MAC + SAP)
* @laddr: address of local LLC (MAC + SAP) * @laddr: address of local LLC (MAC + SAP)
...@@ -405,8 +408,8 @@ static int llc_exec_conn_trans_actions(struct sock *sk, ...@@ -405,8 +408,8 @@ static int llc_exec_conn_trans_actions(struct sock *sk,
* mac, remote sap, local mac, and local sap. Returns pointer for * mac, remote sap, local mac, and local sap. Returns pointer for
* connection found, %NULL otherwise. * connection found, %NULL otherwise.
*/ */
struct sock *llc_find_sock(struct llc_sap *sap, struct llc_addr *daddr, struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr,
struct llc_addr *laddr) struct llc_addr *laddr)
{ {
struct sock *rc = NULL; struct sock *rc = NULL;
struct list_head *entry; struct list_head *entry;
......
...@@ -70,7 +70,7 @@ static llc_prim_call_t llc_resp_prim[LLC_NBR_PRIMITIVES] = { ...@@ -70,7 +70,7 @@ static llc_prim_call_t llc_resp_prim[LLC_NBR_PRIMITIVES] = {
* @lsap: SAP number. * @lsap: SAP number.
* @sap: pointer to allocated SAP (output argument). * @sap: pointer to allocated SAP (output argument).
* *
* Interface function to upper layer. each one who wants to get a SAP * Interface function to upper layer. Each one who wants to get a SAP
* (for example NetBEUI) should call this function. Returns the opened * (for example NetBEUI) should call this function. Returns the opened
* SAP for success, NULL for failure. * SAP for success, NULL for failure.
*/ */
...@@ -110,7 +110,7 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate, ...@@ -110,7 +110,7 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate,
* llc_sap_close - close interface for upper layers. * llc_sap_close - close interface for upper layers.
* @sap: SAP to be closed. * @sap: SAP to be closed.
* *
* Close interface function to upper layer. each one who wants to * Close interface function to upper layer. Each one who wants to
* close an open SAP (for example NetBEUI) should call this function. * close an open SAP (for example NetBEUI) should call this function.
*/ */
void llc_sap_close(struct llc_sap *sap) void llc_sap_close(struct llc_sap *sap)
...@@ -123,9 +123,9 @@ void llc_sap_close(struct llc_sap *sap) ...@@ -123,9 +123,9 @@ void llc_sap_close(struct llc_sap *sap)
* llc_sap_req - Request interface for upper layers * llc_sap_req - Request interface for upper layers
* @prim: pointer to structure that contains service parameters. * @prim: pointer to structure that contains service parameters.
* *
* Request interface function to upper layer. each one who wants to * Request interface function to upper layer. Each one who wants to
* request a service from LLC, must call this function. details of * request a service from LLC, must call this function. Details of
* requested service is defined in input argument(prim). Returns 0 for * requested service is defined in input argument(prim). Returns 0 for
* success, 1 otherwise. * success, 1 otherwise.
*/ */
static int llc_sap_req(struct llc_prim_if_block *prim) static int llc_sap_req(struct llc_prim_if_block *prim)
...@@ -174,7 +174,7 @@ static int llc_unitdata_req_handler(struct llc_prim_if_block *prim) ...@@ -174,7 +174,7 @@ static int llc_unitdata_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = 0; rc = 0;
llc_sap_send_ev(sap, prim->data->udata.skb); llc_sap_state_process(sap, prim->data->udata.skb);
out: out:
return rc; return rc;
} }
...@@ -200,7 +200,7 @@ static int llc_test_req_handler(struct llc_prim_if_block *prim) ...@@ -200,7 +200,7 @@ static int llc_test_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = 0; rc = 0;
llc_sap_send_ev(sap, prim->data->udata.skb); llc_sap_state_process(sap, prim->data->udata.skb);
out: out:
return rc; return rc;
} }
...@@ -227,7 +227,7 @@ static int llc_xid_req_handler(struct llc_prim_if_block *prim) ...@@ -227,7 +227,7 @@ static int llc_xid_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = 0; rc = 0;
llc_sap_send_ev(sap, prim->data->udata.skb); llc_sap_state_process(sap, prim->data->udata.skb);
out: out:
return rc; return rc;
} }
...@@ -237,10 +237,10 @@ static int llc_xid_req_handler(struct llc_prim_if_block *prim) ...@@ -237,10 +237,10 @@ static int llc_xid_req_handler(struct llc_prim_if_block *prim)
* @prim: pointer to structure that contains service parameters * @prim: pointer to structure that contains service parameters
* *
* This function is called when upper layer wants to send data using * This function is called when upper layer wants to send data using
* connection oriented communication mode. during sending data, connection * connection oriented communication mode. During sending data, connection
* will be locked and received frames and expired timers will be queued. * will be locked and received frames and expired timers will be queued.
* Returns 0 for success, -ECONNABORTED when the connection already * Returns 0 for success, -ECONNABORTED when the connection already
* closed. and -EBUSY when sending data is not permitted in this state or * closed and -EBUSY when sending data is not permitted in this state or
* LLC has send an I pdu with p bit set to 1 and is waiting for it's * LLC has send an I pdu with p bit set to 1 and is waiting for it's
* response. * response.
*/ */
...@@ -273,7 +273,7 @@ static int llc_data_req_handler(struct llc_prim_if_block *prim) ...@@ -273,7 +273,7 @@ static int llc_data_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
prim->data->data.skb->dev = llc->dev; prim->data->data.skb->dev = llc->dev;
rc = llc_conn_send_ev(sk, prim->data->data.skb); rc = llc_conn_state_process(sk, prim->data->data.skb);
out: out:
release_sock(sk); release_sock(sk);
return rc; return rc;
...@@ -297,8 +297,8 @@ static void llc_confirm_impossible(struct llc_prim_if_block *prim) ...@@ -297,8 +297,8 @@ static void llc_confirm_impossible(struct llc_prim_if_block *prim)
* @prim: pointer to structure that contains service parameters. * @prim: pointer to structure that contains service parameters.
* *
* Upper layer calls this to establish an LLC connection with a remote * Upper layer calls this to establish an LLC connection with a remote
* machine. this function packages a proper event and sends it connection * machine. This function packages a proper event and sends it connection
* component state machine. Success or failure of connection * component state machine. Success or failure of connection
* establishment will inform to upper layer via calling it's confirm * establishment will inform to upper layer via calling it's confirm
* function and passing proper information. * function and passing proper information.
*/ */
...@@ -323,18 +323,22 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim) ...@@ -323,18 +323,22 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
laddr.lsap = prim->data->conn.saddr.lsap; laddr.lsap = prim->data->conn.saddr.lsap;
memcpy(daddr.mac, prim->data->conn.daddr.mac, sizeof(daddr.mac)); memcpy(daddr.mac, prim->data->conn.daddr.mac, sizeof(daddr.mac));
daddr.lsap = prim->data->conn.daddr.lsap; daddr.lsap = prim->data->conn.daddr.lsap;
sk = llc_find_sock(sap, &daddr, &laddr); sk = llc_lookup_established(sap, &daddr, &laddr);
if (sk) { if (sk) {
llc_confirm_impossible(prim); llc_confirm_impossible(prim);
goto out_put; goto out_put;
} }
rc = -ENOMEM; rc = -ENOMEM;
if (prim->data->conn.sk) { if (prim->data->conn.sk) {
sk = prim->data->conn.sk; sk = prim->data->conn.sk;
if (llc_sock_init(sk)) if (llc_sock_init(sk))
goto out; goto out;
} else { } else {
sk = llc_sock_alloc(); /*
* FIXME: this one will die as soon as core and
* llc_sock starts sharing a struct sock.
*/
sk = llc_sock_alloc(PF_LLC);
if (!sk) { if (!sk) {
llc_confirm_impossible(prim); llc_confirm_impossible(prim);
goto out; goto out;
...@@ -359,7 +363,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim) ...@@ -359,7 +363,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.prim = LLC_CONN_PRIM; ev->data.prim.prim = LLC_CONN_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, skb); rc = llc_conn_state_process(sk, skb);
} }
if (rc) { if (rc) {
llc_sap_unassign_sock(sap, sk); llc_sap_unassign_sock(sap, sk);
...@@ -378,7 +382,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim) ...@@ -378,7 +382,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
* @prim: pointer to structure that contains service parameters. * @prim: pointer to structure that contains service parameters.
* *
* Upper layer calls this when it wants to close an established LLC * Upper layer calls this when it wants to close an established LLC
* connection with a remote machine. this function packages a proper event * connection with a remote machine. This function packages a proper event
* and sends it to connection component state machine. Returns 0 for * and sends it to connection component state machine. Returns 0 for
* success, 1 otherwise. * success, 1 otherwise.
*/ */
...@@ -406,7 +410,7 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim) ...@@ -406,7 +410,7 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.prim = LLC_DISC_PRIM; ev->data.prim.prim = LLC_DISC_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, skb); rc = llc_conn_state_process(sk, skb);
out: out:
release_sock(sk); release_sock(sk);
sock_put(sk); sock_put(sk);
...@@ -418,7 +422,7 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim) ...@@ -418,7 +422,7 @@ static int llc_disc_req_handler(struct llc_prim_if_block *prim)
* @prim: pointer to structure that contains service parameters. * @prim: pointer to structure that contains service parameters.
* *
* Called when upper layer wants to reset an established LLC connection * Called when upper layer wants to reset an established LLC connection
* with a remote machine. this function packages a proper event and sends * with a remote machine. This function packages a proper event and sends
* it to connection component state machine. Returns 0 for success, 1 * it to connection component state machine. Returns 0 for success, 1
* otherwise. * otherwise.
*/ */
...@@ -437,7 +441,7 @@ static int llc_rst_req_handler(struct llc_prim_if_block *prim) ...@@ -437,7 +441,7 @@ static int llc_rst_req_handler(struct llc_prim_if_block *prim)
ev->data.prim.prim = LLC_RESET_PRIM; ev->data.prim.prim = LLC_RESET_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_REQ; ev->data.prim.type = LLC_PRIM_TYPE_REQ;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, skb); rc = llc_conn_state_process(sk, skb);
} }
release_sock(sk); release_sock(sk);
return rc; return rc;
...@@ -455,7 +459,7 @@ static int llc_flowcontrol_req_handler(struct llc_prim_if_block *prim) ...@@ -455,7 +459,7 @@ static int llc_flowcontrol_req_handler(struct llc_prim_if_block *prim)
* llc_sap_resp - Sends response to peer * llc_sap_resp - Sends response to peer
* @prim: pointer to structure that contains service parameters * @prim: pointer to structure that contains service parameters
* *
* This function is a interface function to upper layer. each one who * This function is a interface function to upper layer. Each one who
* wants to response to an indicate can call this function via calling * wants to response to an indicate can call this function via calling
* sap_resp with proper service parameters. Returns 0 for success, 1 * sap_resp with proper service parameters. Returns 0 for success, 1
* otherwise. * otherwise.
...@@ -509,7 +513,7 @@ static int llc_rst_rsp_handler(struct llc_prim_if_block *prim) ...@@ -509,7 +513,7 @@ static int llc_rst_rsp_handler(struct llc_prim_if_block *prim)
ev->data.prim.prim = LLC_RESET_PRIM; ev->data.prim.prim = LLC_RESET_PRIM;
ev->data.prim.type = LLC_PRIM_TYPE_RESP; ev->data.prim.type = LLC_PRIM_TYPE_RESP;
ev->data.prim.data = prim; ev->data.prim.data = prim;
rc = llc_conn_send_ev(sk, skb); rc = llc_conn_state_process(sk, skb);
} }
return rc; return rc;
} }
......
...@@ -67,7 +67,7 @@ int mac_send_pdu(struct sk_buff *skb) ...@@ -67,7 +67,7 @@ int mac_send_pdu(struct sk_buff *skb)
} }
/** /**
* mac_indicate - 802.2 entry point from net lower layers * llc_rcv - 802.2 entry point from net lower layers
* @skb: received pdu * @skb: received pdu
* @dev: device that receive pdu * @dev: device that receive pdu
* @pt: packet type * @pt: packet type
...@@ -78,7 +78,7 @@ int mac_send_pdu(struct sk_buff *skb) ...@@ -78,7 +78,7 @@ int mac_send_pdu(struct sk_buff *skb)
* related to a busy connection (a connection is sending data now), * related to a busy connection (a connection is sending data now),
* function queues this frame in connection's backlog. * function queues this frame in connection's backlog.
*/ */
int mac_indicate(struct sk_buff *skb, struct net_device *dev, int llc_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt) struct packet_type *pt)
{ {
struct llc_sap *sap; struct llc_sap *sap;
...@@ -119,11 +119,14 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev, ...@@ -119,11 +119,14 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
llc_pdu_decode_da(skb, daddr.mac); llc_pdu_decode_da(skb, daddr.mac);
llc_pdu_decode_dsap(skb, &daddr.lsap); llc_pdu_decode_dsap(skb, &daddr.lsap);
sk = llc_find_sock(sap, &saddr, &daddr); sk = llc_lookup_established(sap, &saddr, &daddr);
if (!sk) { /* didn't find an active connection; allocate a if (!sk) {
* connection to use; associate it with this SAP /*
*/ * FIXME: here we'll pass the sk->family of the
sk = llc_sock_alloc(); * listening socket, if found, when
* llc_lookup_listener is added in the next patches.
*/
sk = llc_sock_alloc(PF_LLC);
if (!sk) if (!sk)
goto drop; goto drop;
memcpy(&llc_sk(sk)->daddr, &saddr, sizeof(saddr)); memcpy(&llc_sk(sk)->daddr, &saddr, sizeof(saddr));
...@@ -131,21 +134,10 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev, ...@@ -131,21 +134,10 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
sock_hold(sk); sock_hold(sk);
} }
bh_lock_sock(sk); bh_lock_sock(sk);
if (!sk->lock.users) { if (!sk->lock.users)
/* FIXME: Check this on SMP as it is now calling
* llc_pdu_router _with_ the lock held.
* Old comment:
* With the current code one can't call
* llc_pdu_router with the socket lock held, cause
* it'll route the pdu to the upper layers and it can
* reenter llc and in llc_req_prim will try to grab
* the same lock, maybe we should use spin_trylock_bh
* in the llc_req_prim (llc_data_req_handler, etc) and
* add the request to the backlog, well see...
*/
rc = llc_pdu_router(llc_sk(sk)->sap, sk, skb, rc = llc_pdu_router(llc_sk(sk)->sap, sk, skb,
LLC_TYPE_2); LLC_TYPE_2);
} else { else {
dprintk("%s: add to backlog\n", __FUNCTION__); dprintk("%s: add to backlog\n", __FUNCTION__);
llc_set_backlog_type(skb, LLC_PACKET); llc_set_backlog_type(skb, LLC_PACKET);
sk_add_backlog(sk, skb); sk_add_backlog(sk, skb);
...@@ -203,7 +195,7 @@ static void fix_up_incoming_skb(struct sk_buff *skb) ...@@ -203,7 +195,7 @@ static void fix_up_incoming_skb(struct sk_buff *skb)
* is NULL then data unit destined for station else frame destined for SAP * is NULL then data unit destined for station else frame destined for SAP
* or connection; finds a matching open SAP, if one, forwards the packet * or connection; finds a matching open SAP, if one, forwards the packet
* to it; if no matching SAP, drops the packet. Returns 0 or the return of * to it; if no matching SAP, drops the packet. Returns 0 or the return of
* llc_conn_send_ev (that may well result in the connection being * llc_conn_state_process (that may well result in the connection being
* destroyed) * destroyed)
*/ */
int llc_pdu_router(struct llc_sap *sap, struct sock* sk, int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
...@@ -218,13 +210,13 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk, ...@@ -218,13 +210,13 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
ev->type = LLC_STATION_EV_TYPE_PDU; ev->type = LLC_STATION_EV_TYPE_PDU;
ev->data.pdu.reason = 0; ev->data.pdu.reason = 0;
llc_station_send_ev(station, skb); llc_station_state_process(station, skb);
} else if (type == LLC_TYPE_1) { } else if (type == LLC_TYPE_1) {
struct llc_sap_state_ev *ev = llc_sap_ev(skb); struct llc_sap_state_ev *ev = llc_sap_ev(skb);
ev->type = LLC_SAP_EV_TYPE_PDU; ev->type = LLC_SAP_EV_TYPE_PDU;
ev->data.pdu.reason = 0; ev->data.pdu.reason = 0;
llc_sap_send_ev(sap, skb); llc_sap_state_process(sap, skb);
} else if (type == LLC_TYPE_2) { } else if (type == LLC_TYPE_2) {
struct llc_conn_state_ev *ev = llc_conn_ev(skb); struct llc_conn_state_ev *ev = llc_conn_ev(skb);
struct llc_opt *llc = llc_sk(sk); struct llc_opt *llc = llc_sk(sk);
...@@ -234,7 +226,7 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk, ...@@ -234,7 +226,7 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
ev->type = LLC_CONN_EV_TYPE_PDU; ev->type = LLC_CONN_EV_TYPE_PDU;
ev->data.pdu.reason = 0; ev->data.pdu.reason = 0;
rc = llc_conn_send_ev(sk, skb); rc = llc_conn_state_process(sk, skb);
} else } else
rc = -EINVAL; rc = -EINVAL;
return rc; return rc;
......
...@@ -136,7 +136,7 @@ struct llc_sap *llc_sap_find(u8 sap_value) ...@@ -136,7 +136,7 @@ struct llc_sap *llc_sap_find(u8 sap_value)
* *
* This function processes frames that has received and timers that has * This function processes frames that has received and timers that has
* expired during sending an I pdu (refer to data_req_handler). frames * expired during sending an I pdu (refer to data_req_handler). frames
* queue by mac_indicate function (llc_mac.c) and timers queue by timer * queue by llc_rcv function (llc_mac.c) and timers queue by timer
* callback functions(llc_c_ac.c). * callback functions(llc_c_ac.c).
*/ */
static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb) static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
...@@ -152,7 +152,7 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -152,7 +152,7 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
} else if (llc_backlog_type(skb) == LLC_EVENT) { } else if (llc_backlog_type(skb) == LLC_EVENT) {
/* timer expiration event */ /* timer expiration event */
if (llc->state > 1) /* not closed */ if (llc->state > 1) /* not closed */
rc = llc_conn_send_ev(sk, skb); rc = llc_conn_state_process(sk, skb);
else else
llc_conn_free_ev(skb); llc_conn_free_ev(skb);
kfree_skb(skb); kfree_skb(skb);
...@@ -199,13 +199,14 @@ int llc_sock_init(struct sock* sk) ...@@ -199,13 +199,14 @@ int llc_sock_init(struct sock* sk)
/** /**
* __llc_sock_alloc - Allocates LLC sock * __llc_sock_alloc - Allocates LLC sock
* @family: upper layer protocol family
* *
* Allocates a LLC sock and initializes it. Returns the new LLC sock * Allocates a LLC sock and initializes it. Returns the new LLC sock
* or %NULL if there's no memory available for one * or %NULL if there's no memory available for one
*/ */
struct sock *__llc_sock_alloc(void) struct sock *__llc_sock_alloc(int family)
{ {
struct sock *sk = sk_alloc(PF_LLC, GFP_ATOMIC, 1, NULL); struct sock *sk = sk_alloc(family, GFP_ATOMIC, 1, NULL);
if (!sk) if (!sk)
goto out; goto out;
...@@ -319,14 +320,14 @@ struct llc_station *llc_station_get(void) ...@@ -319,14 +320,14 @@ struct llc_station *llc_station_get(void)
} }
/** /**
* llc_station_send_ev: queue event and try to process queue. * llc_station_state_process: queue event and try to process queue.
* @station: Address of the station * @station: Address of the station
* @skb: Address of the event * @skb: Address of the event
* *
* Queues an event (on the station event queue) for handling by the * Queues an event (on the station event queue) for handling by the
* station state machine and attempts to process any queued-up events. * station state machine and attempts to process any queued-up events.
*/ */
void llc_station_send_ev(struct llc_station *station, struct sk_buff *skb) void llc_station_state_process(struct llc_station *station, struct sk_buff *skb)
{ {
spin_lock_bh(&station->ev_q.lock); spin_lock_bh(&station->ev_q.lock);
skb_queue_tail(&station->ev_q.list, skb); skb_queue_tail(&station->ev_q.list, skb);
...@@ -556,13 +557,13 @@ static int llc_proc_get_info(char *bf, char **start, off_t offset, int length) ...@@ -556,13 +557,13 @@ static int llc_proc_get_info(char *bf, char **start, off_t offset, int length)
static struct packet_type llc_packet_type = { static struct packet_type llc_packet_type = {
.type = __constant_htons(ETH_P_802_2), .type = __constant_htons(ETH_P_802_2),
.func = mac_indicate, .func = llc_rcv,
.data = (void *)1, .data = (void *)1,
}; };
static struct packet_type llc_tr_packet_type = { static struct packet_type llc_tr_packet_type = {
.type = __constant_htons(ETH_P_TR_802_2), .type = __constant_htons(ETH_P_TR_802_2),
.func = mac_indicate, .func = llc_rcv,
.data = (void *)1, .data = (void *)1,
}; };
......
...@@ -63,14 +63,14 @@ void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk) ...@@ -63,14 +63,14 @@ void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk)
} }
/** /**
* llc_sap_send_ev - sends event to SAP state machine * llc_sap_state_process - sends event to SAP state machine
* @sap: pointer to SAP * @sap: pointer to SAP
* @skb: pointer to occurred event * @skb: pointer to occurred event
* *
* After executing actions of the event, upper layer will be indicated * After executing actions of the event, upper layer will be indicated
* if needed(on receiving an UI frame). * if needed(on receiving an UI frame).
*/ */
void llc_sap_send_ev(struct llc_sap *sap, struct sk_buff *skb) void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb)
{ {
struct llc_sap_state_ev *ev = llc_sap_ev(skb); struct llc_sap_state_ev *ev = llc_sap_ev(skb);
......
...@@ -63,7 +63,7 @@ static int llc_ui_wait_for_disc(struct sock *sk, int seconds); ...@@ -63,7 +63,7 @@ static int llc_ui_wait_for_disc(struct sock *sk, int seconds);
* *
* Return the next unused link number for a given sap. * Return the next unused link number for a given sap.
*/ */
static inline u16 llc_ui_next_link_no(int sap) static __inline__ u16 llc_ui_next_link_no(int sap)
{ {
return llc_ui_sap_link_no_max[sap]++; return llc_ui_sap_link_no_max[sap]++;
} }
...@@ -77,7 +77,7 @@ static inline u16 llc_ui_next_link_no(int sap) ...@@ -77,7 +77,7 @@ static inline u16 llc_ui_next_link_no(int sap)
* is not a complete match up to len, 1 if a complete match up to len is * is not a complete match up to len, 1 if a complete match up to len is
* found. * found.
*/ */
static inline u8 llc_ui_mac_match(u8 *mac1, u8 *mac2) static __inline__ u8 llc_ui_mac_match(u8 *mac1, u8 *mac2)
{ {
return !memcmp(mac1, mac2, IFHWADDRLEN); return !memcmp(mac1, mac2, IFHWADDRLEN);
} }
...@@ -89,7 +89,7 @@ static inline u8 llc_ui_mac_match(u8 *mac1, u8 *mac2) ...@@ -89,7 +89,7 @@ static inline u8 llc_ui_mac_match(u8 *mac1, u8 *mac2)
* Determines if a given address is a null mac address. Returns 0 if the * Determines if a given address is a null mac address. Returns 0 if the
* address is not a null mac, 1 if the address is a null mac. * address is not a null mac, 1 if the address is a null mac.
*/ */
static inline u8 llc_ui_mac_null(u8 *mac) static __inline__ u8 llc_ui_mac_null(u8 *mac)
{ {
return !memcmp(mac, llc_ui_addrany, IFHWADDRLEN); return !memcmp(mac, llc_ui_addrany, IFHWADDRLEN);
} }
...@@ -98,7 +98,7 @@ static inline u8 llc_ui_mac_null(u8 *mac) ...@@ -98,7 +98,7 @@ static inline u8 llc_ui_mac_null(u8 *mac)
* llc_ui_addr_null - determines if a address structure is null * llc_ui_addr_null - determines if a address structure is null
* @addr: Address to test if null. * @addr: Address to test if null.
*/ */
static inline u8 llc_ui_addr_null(struct sockaddr_llc *addr) static __inline__ u8 llc_ui_addr_null(struct sockaddr_llc *addr)
{ {
return !memcmp(addr, &llc_ui_addrnull, sizeof(*addr)); return !memcmp(addr, &llc_ui_addrnull, sizeof(*addr));
} }
...@@ -111,7 +111,7 @@ static inline u8 llc_ui_addr_null(struct sockaddr_llc *addr) ...@@ -111,7 +111,7 @@ static inline u8 llc_ui_addr_null(struct sockaddr_llc *addr)
* Returns 0 if ARP header type not supported or the corresponding * Returns 0 if ARP header type not supported or the corresponding
* ethernet protocol type. * ethernet protocol type.
*/ */
static inline u16 llc_ui_protocol_type(u16 arphrd) static __inline__ u16 llc_ui_protocol_type(u16 arphrd)
{ {
u16 rc = htons(ETH_P_802_2); u16 rc = htons(ETH_P_802_2);
...@@ -129,7 +129,8 @@ static inline u16 llc_ui_protocol_type(u16 arphrd) ...@@ -129,7 +129,8 @@ static inline u16 llc_ui_protocol_type(u16 arphrd)
* operation the user would like to perform and the type of socket. * operation the user would like to perform and the type of socket.
* Returns the correct llc header length. * Returns the correct llc header length.
*/ */
static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr) static __inline__ u8 llc_ui_header_len(struct sock *sk,
struct sockaddr_llc *addr)
{ {
u8 rc = LLC_PDU_LEN_U; u8 rc = LLC_PDU_LEN_U;
...@@ -280,7 +281,7 @@ static int llc_ui_send_llc1(struct llc_sap *sap, struct sk_buff *skb, ...@@ -280,7 +281,7 @@ static int llc_ui_send_llc1(struct llc_sap *sap, struct sk_buff *skb,
* structure which matches the sap number the user specified. * structure which matches the sap number the user specified.
* Returns llc_sap upon match, %NULL otherwise. * Returns llc_sap upon match, %NULL otherwise.
*/ */
static inline struct llc_sap *llc_ui_find_sap(u8 sap) static __inline__ struct llc_sap *llc_ui_find_sap(u8 sap)
{ {
struct sock *sk; struct sock *sk;
struct llc_sap *s = NULL; struct llc_sap *s = NULL;
...@@ -399,7 +400,7 @@ static struct sock *llc_ui_bh_find_sk_by_addr(struct llc_addr *addr, ...@@ -399,7 +400,7 @@ static struct sock *llc_ui_bh_find_sk_by_addr(struct llc_addr *addr,
* *
* Insert a socket into the local llc socket list. * Insert a socket into the local llc socket list.
*/ */
static inline void llc_ui_insert_socket(struct sock *sk) static __inline__ void llc_ui_insert_socket(struct sock *sk)
{ {
write_lock_bh(&llc_ui_sockets_lock); write_lock_bh(&llc_ui_sockets_lock);
sk->next = llc_ui_sockets; sk->next = llc_ui_sockets;
...@@ -417,7 +418,7 @@ static inline void llc_ui_insert_socket(struct sock *sk) ...@@ -417,7 +418,7 @@ static inline void llc_ui_insert_socket(struct sock *sk)
* *
* Remove a socket from the local llc socket list. * Remove a socket from the local llc socket list.
*/ */
static inline void llc_ui_remove_socket(struct sock *sk) static __inline__ void llc_ui_remove_socket(struct sock *sk)
{ {
write_lock_bh(&llc_ui_sockets_lock); write_lock_bh(&llc_ui_sockets_lock);
if (sk->pprev) { if (sk->pprev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment