===== net/bluetooth/bnep/core.c 1.30 vs edited ===== --- 1.30/net/bluetooth/bnep/core.c 2004-07-26 19:46:35 +02:00 +++ edited/net/bluetooth/bnep/core.c 2004-07-29 09:46:45 +02:00 @@ -61,7 +61,7 @@ #define BT_DBG(D...) #endif -#define VERSION "1.0" +#define VERSION "1.1" static LIST_HEAD(bnep_session_list); static DECLARE_RWSEM(bnep_session_sem); @@ -113,6 +113,23 @@ return bnep_send(s, &rsp, sizeof(rsp)); } +#ifdef CONFIG_BT_BNEP_PROTO_FILTER +static inline void bnep_set_default_proto_filter(struct bnep_session *s) +{ + memset(s->proto_filter, 0, sizeof(struct bnep_proto_filter) * BNEP_MAX_PROTO_FILTERS); + + /* (IPv4, ARP) */ + s->proto_filter[0].start = htons(0x0800); + s->proto_filter[0].end = htons(0x0806); + /* (RARP, AppleTalk) */ + s->proto_filter[1].start = htons(0x8035); + s->proto_filter[1].end = htons(0x80F3); + /* (IPX, IPv6) */ + s->proto_filter[2].start = htons(0x8137); + s->proto_filter[2].end = htons(0x86DD); +} +#endif + static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len) { int n; @@ -131,18 +148,21 @@ #ifdef CONFIG_BT_BNEP_PROTO_FILTER n /= 4; if (n <= BNEP_MAX_PROTO_FILTERS) { - struct bnep_proto_filter *f = s->proto_filter; - int i; + if (n > 0) { + struct bnep_proto_filter *f = s->proto_filter; + int i; + + for (i = 0; i < n; i++) { + f[i].start = get_unaligned(data++); + f[i].end = get_unaligned(data++); - for (i = 0; i < n; i++) { - f[i].start = get_unaligned(data++); - f[i].end = get_unaligned(data++); - - BT_DBG("proto filter start %d end %d", - f[i].start, f[i].end); - } - if (i < BNEP_MAX_PROTO_FILTERS) - memset(f + i, 0, sizeof(*f)); + BT_DBG("proto filter start %d end %d", + f[i].start, f[i].end); + } + if (i < BNEP_MAX_PROTO_FILTERS) + memset(f + i, 0, sizeof(*f)); + } else + bnep_set_default_proto_filter(s); bnep_send_rsp(s, BNEP_FILTER_NET_TYPE_RSP, BNEP_SUCCESS); } else { @@ -547,18 +566,9 @@ #ifdef CONFIG_BT_BNEP_PROTO_FILTER /* Set default protocol filter */ - - /* (IPv4, ARP) */ - s->proto_filter[0].start = htons(0x0800); - s->proto_filter[0].end = htons(0x0806); - /* (RARP, AppleTalk) */ - s->proto_filter[1].start = htons(0x8035); - s->proto_filter[1].end = htons(0x80F3); - /* (IPX, IPv6) */ - s->proto_filter[2].start = htons(0x8137); - s->proto_filter[2].end = htons(0x86DD); + bnep_set_default_proto_filter(s); #endif - + err = register_netdev(dev); if (err) { goto failed;