return offset;
}
-
-
-#ifdef REMOVED
-/* to serve as inspiration when implementing ppp over rfcomm */
-static void *my_malloc(int size) {
-
-/* void *p = calloc(size, 1); */
-
- if (!p) {
-/* perror("calloc()"); */
- /* exit(1); */
- }
- return p;
-}
-
-
-static void stream_buf_init(dlci_stream *s)
-{
- s->len = DEFAULT_STREAM_BUF_SIZE;
- s->mode = 0;
- s->is_escaped = 0;
- s->current = 0;
- s->stream_buf = my_malloc(DEFAULT_STREAM_BUF_SIZE);
-}
-
-
-static void stream_buf_append(rfcomm_packet_state *rps,
- dlci_stream *ds, tvbuff_t *tvb,
- int off, int len) {
-
- const guint8 *buf = tvb_get_ptr(tvb, off, len);
- int bytes_left = len, curr = 0;
-
- if (!ds->stream_buf)
- stream_buf_init(ds);
-
- for (bytes_left = len; bytes_left > 0 && ds->current < ds->len; bytes_left--) {
-
- /* fetch next byte */
-
- guint8 byte = buf[curr++];
-
- /* eventually check mode here */
-
- if (byte == 0x7e) {
- if (ds->current == 0)
- continue; /* was start delimiter */
-
- /* end delimiter*/
-
- add_ppp_frame(rps, ds->stream_buf, ds->current);
-
- ds->current = 0;
- ds->is_escaped = 0;
- continue;
- }
-
- if (ds->is_escaped) {
- ds->stream_buf[ds->current++] = byte ^ 0x20;
- ds->is_escaped = 0;
- } else {
- if (byte == 0x7d)
- ds->is_escaped = 1;
- else
- ds->stream_buf[ds->current++] = byte;
- }
-
- }
-}
-
-
-void add_ppp_frame(rfcomm_packet_state *rps, guint8 *buf, int len) {
-
- rfcomm_ppp_frame *ppp = my_malloc(len + sizeof(rfcomm_ppp_frame));
-
- ppp->next = NULL;
- ppp->len = len;
- memcpy(ppp + 1, buf, len);
-
- if (rps->ppp_first)
- rps->ppp_last->next = ppp;
- else
- rps->ppp_first = ppp;
-
- rps->ppp_last = ppp;
-}
-
-/*
-int decode_fragments(dlci_stream *pstream, guint8 *buf) {
-
- int real_len = 0, is_escaped = 0, chunk_index = 0;
- ppp_chunk *chunk_curr = pstream->first;
-
- for (real_len = 0; chunk_curr;) {
-
- guint8 byte;
-
- byte = chunk_curr->buf[chunk_index++];
- if (chunk_index >= chunk_curr->len) {
- chunk_index = 0;
- chunk_curr = chunk_curr->next;
- }
- if (is_escaped) {
- buf[real_len++] = byte ^ 0x20;
- is_escaped = 0;
- } else {
- if (byte == 0x7d)
- is_escaped = 1;
- else
- buf[real_len++] = byte;
- }
-
- }
- return real_len;
-}
-*/
-#endif
-
-
static int
dissect_ctrl_msc(proto_tree *t, tvbuff_t *tvb, int offset, int length)
{
call_dissector(data_handle, next_tvb, pinfo, tree);
}
-
proto_tree_add_item(rfcomm_tree, hf_fcs, tvb, fcs_offset, 1, TRUE);
-
-
-#ifdef REMOVED
-/* to serve as inspiration when implementing ppp over rfcomm */
- rfcomm_packet_state *rps = p_get_proto_data(pinfo->fd, proto_btrfcomm);
- proto_item *ti_main, *ti_addr, *ti_hctl, *ti;
- proto_tree *st, *st_ctrl, *st_addr, *st_hctl;
- int size, off, off_fcs
-
- if (rps == NULL) {
- rps = my_malloc(sizeof(rfcomm_packet_state));
- rps->ppp_first = NULL;
- rps->ppp_last = NULL;
- p_add_proto_data(pinfo->fd, proto_btrfcomm, rps);
- }
-
-
-
- if(dlci&&frame_len){
- tvbuff_t *next_tvb;
-
- if (frame_type == 0xef && !pinfo->fd->flags.visited) {
- dlci_stream *ds;
-
- ds = &state[dlci].direction[cr_flag];
- stream_buf_append(rps, ds, tvb, off, frame_len);
- }
-
- if (rps && rps->ppp_first) {
- rfcomm_ppp_frame *p;
-
- for (p = rps->ppp_first; p; p = p->next) {
- next_tvb = tvb_new_child_real_data(tvb, (guint8 *) (p + 1), p->len, p->len);
- packet_add_new_data_source(pinfo, rfcomm_tree, next_tvb, "Reassembled PPP frame");
- call_dissector(ppp_handle, next_tvb, pinfo, tree);
- }
- } else {
- next_tvb = tvb_new_subset(tvb, off, frame_len, frame_len);
- call_dissector(data_handle, next_tvb, pinfo, tree);
- }
- }
-#endif
}