1 /* librfid - layer 3 protocol handler
2 * (C) 2005 by Harald Welte <laforge@gnumonks.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <librfid/rfid_layer2.h>
25 #include <librfid/rfid_protocol.h>
27 static struct rfid_protocol *rfid_protocol_list;
29 struct rfid_protocol_handle *
30 rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id)
32 struct rfid_protocol *p;
33 struct rfid_protocol_handle *ph = NULL;
35 for (p = rfid_protocol_list; p; p = p->next) {
52 rfid_protocol_open(struct rfid_protocol_handle *ph)
54 if (ph->proto->fn.open)
55 return ph->proto->fn.open(ph);
60 rfid_protocol_transcieve(struct rfid_protocol_handle *ph,
61 const unsigned char *tx_buf, unsigned int len,
62 unsigned char *rx_buf, unsigned int *rx_len,
63 unsigned int timeout, unsigned int flags)
65 return ph->proto->fn.transcieve(ph, tx_buf, len, rx_buf, rx_len,
70 rfid_protocol_read(struct rfid_protocol_handle *ph,
72 unsigned char *rx_data,
75 if (ph->proto->fn.read)
76 return ph->proto->fn.read(ph, page, rx_data, rx_len);
82 rfid_protocol_write(struct rfid_protocol_handle *ph,
84 unsigned char *tx_data,
87 if (ph->proto->fn.write)
88 return ph->proto->fn.write(ph, page, tx_data, tx_len);
93 int rfid_protocol_fini(struct rfid_protocol_handle *ph)
95 return ph->proto->fn.fini(ph);
99 rfid_protocol_close(struct rfid_protocol_handle *ph)
101 if (ph->proto->fn.close)
102 return ph->proto->fn.close(ph);
107 rfid_protocol_register(struct rfid_protocol *p)
109 p->next = rfid_protocol_list;
110 rfid_protocol_list = p;