1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include "irnet_ppp.h"
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36static inline ssize_t
37irnet_ctrl_write(irnet_socket * ap,
38 const char * buf,
39 size_t count)
40{
41 char command[IRNET_MAX_COMMAND];
42 char * start;
43 char * next;
44 int length;
45
46 DENTER(CTRL_TRACE, "(ap=0x%X, count=%d)\n", (unsigned int) ap, count);
47
48
49 DABORT(count >= IRNET_MAX_COMMAND, -ENOMEM,
50 CTRL_ERROR, "Too much data !!!\n");
51
52
53 if(copy_from_user(command, buf, count))
54 {
55 DERROR(CTRL_ERROR, "Invalid user space pointer.\n");
56 return -EFAULT;
57 }
58
59
60 command[count] = '\0';
61 DEBUG(CTRL_INFO, "Command line received is ``%s'' (%d).\n",
62 command, count);
63
64
65 next = command;
66 while(next != NULL)
67 {
68
69 start = next;
70
71
72 while(isspace(*start))
73 start++;
74
75
76 next = strchr(start, ',');
77 if(next)
78 {
79 *next = '\0';
80 length = next - start;
81 next++;
82 }
83 else
84 length = strlen(start);
85
86 DEBUG(CTRL_INFO, "Found command ``%s'' (%d).\n", start, length);
87
88
89
90
91
92 if(!strncmp(start, "name", 4))
93 {
94
95 if((length > 5) && (strcmp(start + 5, "any")))
96 {
97
98 while(isspace(start[length - 1]))
99 length--;
100
101
102 memcpy(ap->rname, start + 5, length - 5);
103 ap->rname[length - 5] = '\0';
104 }
105 else
106 ap->rname[0] = '\0';
107 DEBUG(CTRL_INFO, "Got rname = ``%s''\n", ap->rname);
108
109
110 continue;
111 }
112
113
114
115 if((!strncmp(start, "addr", 4)) ||
116 (!strncmp(start, "daddr", 5)) ||
117 (!strncmp(start, "saddr", 5)))
118 {
119 __u32 addr = DEV_ADDR_ANY;
120
121
122 if((length > 5) && (strcmp(start + 5, "any")))
123 {
124 char * begp = start + 5;
125 char * endp;
126
127
128 while(isspace(*begp))
129 begp++;
130
131
132 addr = simple_strtoul(begp, &endp, 16);
133
134 DABORT(endp <= (start + 5), -EINVAL,
135 CTRL_ERROR, "Invalid address.\n");
136 }
137
138 if(start[0] == 's')
139 {
140
141 ap->rsaddr = addr;
142 DEBUG(CTRL_INFO, "Got rsaddr = %08x\n", ap->rsaddr);
143 }
144 else
145 {
146
147 ap->rdaddr = addr;
148 DEBUG(CTRL_INFO, "Got rdaddr = %08x\n", ap->rdaddr);
149 }
150
151
152 continue;
153 }
154
155
156
157
158 DABORT(1, -EINVAL, CTRL_ERROR, "Not a recognised IrNET command.\n");
159 }
160
161
162 return(count);
163}
164
165#ifdef INITIAL_DISCOVERY
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181static inline int
182irnet_read_discovery_log(irnet_socket * ap,
183 char * event)
184{
185 int done_event = 0;
186
187 DENTER(CTRL_TRACE, "(ap=0x%X, event=0x%X)\n",
188 (unsigned int) ap, (unsigned int) event);
189
190
191 if(ap->disco_number == -1)
192 {
193 DEBUG(CTRL_INFO, "Already done\n");
194 return 0;
195 }
196
197
198 if(ap->disco_index == 0)
199 {
200 __u16 mask = irlmp_service_to_hint(S_LAN);
201
202
203 ap->discoveries = irlmp_get_discoveries(&ap->disco_number, mask,
204 DISCOVERY_DEFAULT_SLOTS);
205
206 if(ap->discoveries == NULL)
207 ap->disco_number = -1;
208 DEBUG(CTRL_INFO, "Got the log (0x%X), size is %d\n",
209 (unsigned int) ap->discoveries, ap->disco_number);
210 }
211
212
213 if(ap->disco_index < ap->disco_number)
214 {
215
216 sprintf(event, "Found %08x (%s) behind %08x\n",
217 ap->discoveries[ap->disco_index].daddr,
218 ap->discoveries[ap->disco_index].info,
219 ap->discoveries[ap->disco_index].saddr);
220 DEBUG(CTRL_INFO, "Writing discovery %d : %s\n",
221 ap->disco_index, ap->discoveries[ap->disco_index].info);
222
223
224 done_event = 1;
225
226 ap->disco_index++;
227 }
228
229
230 if(ap->disco_index >= ap->disco_number)
231 {
232
233 DEBUG(CTRL_INFO, "Cleaning up log (0x%X)\n",
234 (unsigned int) ap->discoveries);
235 if(ap->discoveries != NULL)
236 {
237
238 kfree(ap->discoveries);
239 ap->discoveries = NULL;
240 }
241 ap->disco_number = -1;
242 }
243
244 return done_event;
245}
246#endif
247
248
249
250
251
252static inline ssize_t
253irnet_ctrl_read(irnet_socket * ap,
254 struct file * file,
255 char * buf,
256 size_t count)
257{
258 DECLARE_WAITQUEUE(wait, current);
259 char event[64];
260 ssize_t ret = 0;
261
262 DENTER(CTRL_TRACE, "(ap=0x%X, count=%d)\n", (unsigned int) ap, count);
263
264
265 DABORT(count < sizeof(event), -EOVERFLOW, CTRL_ERROR, "Buffer to small.\n");
266
267#ifdef INITIAL_DISCOVERY
268
269 if(irnet_read_discovery_log(ap, event))
270 {
271
272 if(copy_to_user(buf, event, strlen(event)))
273 {
274 DERROR(CTRL_ERROR, "Invalid user space pointer.\n");
275 return -EFAULT;
276 }
277
278 DEXIT(CTRL_TRACE, "\n");
279 return(strlen(event));
280 }
281#endif
282
283
284 add_wait_queue(&irnet_events.rwait, &wait);
285 current->state = TASK_INTERRUPTIBLE;
286 for(;;)
287 {
288
289 ret = 0;
290 if(ap->event_index != irnet_events.index)
291 break;
292 ret = -EAGAIN;
293 if(file->f_flags & O_NONBLOCK)
294 break;
295 ret = -ERESTARTSYS;
296 if(signal_pending(current))
297 break;
298
299 schedule();
300 }
301 current->state = TASK_RUNNING;
302 remove_wait_queue(&irnet_events.rwait, &wait);
303
304
305 if(ret != 0)
306 {
307
308 DEXIT(CTRL_TRACE, " - ret %d\n", ret);
309 return ret;
310 }
311
312
313 switch(irnet_events.log[ap->event_index].event)
314 {
315 case IRNET_DISCOVER:
316 sprintf(event, "Discovered %08x (%s) behind %08x\n",
317 irnet_events.log[ap->event_index].daddr,
318 irnet_events.log[ap->event_index].name,
319 irnet_events.log[ap->event_index].saddr);
320 break;
321 case IRNET_EXPIRE:
322 sprintf(event, "Expired %08x (%s) behind %08x\n",
323 irnet_events.log[ap->event_index].daddr,
324 irnet_events.log[ap->event_index].name,
325 irnet_events.log[ap->event_index].saddr);
326 break;
327 case IRNET_CONNECT_TO:
328 sprintf(event, "Connected to %08x (%s) on ppp%d\n",
329 irnet_events.log[ap->event_index].daddr,
330 irnet_events.log[ap->event_index].name,
331 irnet_events.log[ap->event_index].unit);
332 break;
333 case IRNET_CONNECT_FROM:
334 sprintf(event, "Connection from %08x (%s) on ppp%d\n",
335 irnet_events.log[ap->event_index].daddr,
336 irnet_events.log[ap->event_index].name,
337 irnet_events.log[ap->event_index].unit);
338 break;
339 case IRNET_REQUEST_FROM:
340 sprintf(event, "Request from %08x (%s) behind %08x\n",
341 irnet_events.log[ap->event_index].daddr,
342 irnet_events.log[ap->event_index].name,
343 irnet_events.log[ap->event_index].saddr);
344 break;
345 case IRNET_NOANSWER_FROM:
346 sprintf(event, "No-answer from %08x (%s) on ppp%d\n",
347 irnet_events.log[ap->event_index].daddr,
348 irnet_events.log[ap->event_index].name,
349 irnet_events.log[ap->event_index].unit);
350 break;
351 case IRNET_BLOCKED_LINK:
352 sprintf(event, "Blocked link with %08x (%s) on ppp%d\n",
353 irnet_events.log[ap->event_index].daddr,
354 irnet_events.log[ap->event_index].name,
355 irnet_events.log[ap->event_index].unit);
356 break;
357 case IRNET_DISCONNECT_FROM:
358 sprintf(event, "Disconnection from %08x (%s) on ppp%d\n",
359 irnet_events.log[ap->event_index].daddr,
360 irnet_events.log[ap->event_index].name,
361 irnet_events.log[ap->event_index].unit);
362 break;
363 case IRNET_DISCONNECT_TO:
364 sprintf(event, "Disconnected to %08x (%s)\n",
365 irnet_events.log[ap->event_index].daddr,
366 irnet_events.log[ap->event_index].name);
367 break;
368 default:
369 sprintf(event, "Bug\n");
370 }
371
372 ap->event_index = (ap->event_index + 1) % IRNET_MAX_EVENTS;
373
374 DEBUG(CTRL_INFO, "Event is :%s", event);
375
376
377 if(copy_to_user(buf, event, strlen(event)))
378 {
379 DERROR(CTRL_ERROR, "Invalid user space pointer.\n");
380 return -EFAULT;
381 }
382
383 DEXIT(CTRL_TRACE, "\n");
384 return(strlen(event));
385}
386
387
388
389
390
391
392static inline unsigned int
393irnet_ctrl_poll(irnet_socket * ap,
394 struct file * file,
395 poll_table * wait)
396{
397 unsigned int mask;
398
399 DENTER(CTRL_TRACE, "(ap=0x%X)\n", (unsigned int) ap);
400
401 poll_wait(file, &irnet_events.rwait, wait);
402 mask = POLLOUT | POLLWRNORM;
403
404 if(ap->event_index != irnet_events.index)
405 mask |= POLLIN | POLLRDNORM;
406#ifdef INITIAL_DISCOVERY
407 if(ap->disco_number != -1)
408 mask |= POLLIN | POLLRDNORM;
409#endif
410
411 DEXIT(CTRL_TRACE, " - mask=0x%X\n", mask);
412 return mask;
413}
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429static int
430dev_irnet_open(struct inode * inode,
431 struct file * file)
432{
433 struct irnet_socket * ap;
434 int err;
435
436 DENTER(FS_TRACE, "(file=0x%X)\n", (unsigned int) file);
437
438#ifdef SECURE_DEVIRNET
439
440 if(!capable(CAP_NET_ADMIN))
441 return -EPERM;
442#endif
443
444
445 ap = kmalloc(sizeof(*ap), GFP_KERNEL);
446 DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n");
447
448 MOD_INC_USE_COUNT;
449
450
451 memset(ap, 0, sizeof(*ap));
452 ap->file = file;
453
454
455 ap->ppp_open = 0;
456 ap->chan.private = ap;
457 ap->chan.ops = &irnet_ppp_ops;
458 ap->chan.mtu = (2048 - TTP_MAX_HEADER - 2 - PPP_HDRLEN);
459 ap->chan.hdrlen = 2 + TTP_MAX_HEADER;
460
461 ap->mru = (2048 - TTP_MAX_HEADER - 2 - PPP_HDRLEN);
462 ap->xaccm[0] = ~0U;
463 ap->xaccm[3] = 0x60000000U;
464 ap->raccm = ~0U;
465
466
467 err = irda_irnet_create(ap);
468 if(err)
469 {
470 DERROR(FS_ERROR, "Can't setup IrDA link...\n");
471 kfree(ap);
472 MOD_DEC_USE_COUNT;
473 return err;
474 }
475
476
477 ap->event_index = irnet_events.index;
478
479
480 file->private_data = ap;
481
482 DEXIT(FS_TRACE, " - ap=0x%X\n", (unsigned int) ap);
483 return 0;
484}
485
486
487
488
489
490
491
492static int
493dev_irnet_close(struct inode * inode,
494 struct file * file)
495{
496 irnet_socket * ap = (struct irnet_socket *) file->private_data;
497
498 DENTER(FS_TRACE, "(file=0x%X, ap=0x%X)\n",
499 (unsigned int) file, (unsigned int) ap);
500 DABORT(ap == NULL, 0, FS_ERROR, "ap is NULL !!!\n");
501
502
503 file->private_data = NULL;
504
505
506 irda_irnet_destroy(ap);
507
508
509 if(ap->ppp_open)
510 {
511 DERROR(FS_ERROR, "Channel still registered - deregistering !\n");
512 ppp_unregister_channel(&ap->chan);
513 ap->ppp_open = 0;
514 }
515
516 kfree(ap);
517 MOD_DEC_USE_COUNT;
518
519 DEXIT(FS_TRACE, "\n");
520 return 0;
521}
522
523
524
525
526
527
528static ssize_t
529dev_irnet_write(struct file * file,
530 const char * buf,
531 size_t count,
532 loff_t * ppos)
533{
534 irnet_socket * ap = (struct irnet_socket *) file->private_data;
535
536 DPASS(FS_TRACE, "(file=0x%X, ap=0x%X, count=%d)\n",
537 (unsigned int) file, (unsigned int) ap, count);
538 DABORT(ap == NULL, -ENXIO, FS_ERROR, "ap is NULL !!!\n");
539
540
541 if(ap->ppp_open)
542 return -EAGAIN;
543 else
544 return irnet_ctrl_write(ap, buf, count);
545}
546
547
548
549
550
551
552static ssize_t
553dev_irnet_read(struct file * file,
554 char * buf,
555 size_t count,
556 loff_t * ppos)
557{
558 irnet_socket * ap = (struct irnet_socket *) file->private_data;
559
560 DPASS(FS_TRACE, "(file=0x%X, ap=0x%X, count=%d)\n",
561 (unsigned int) file, (unsigned int) ap, count);
562 DABORT(ap == NULL, -ENXIO, FS_ERROR, "ap is NULL !!!\n");
563
564
565 if(ap->ppp_open)
566 return -EAGAIN;
567 else
568 return irnet_ctrl_read(ap, file, buf, count);
569}
570
571
572
573
574
575static unsigned int
576dev_irnet_poll(struct file * file,
577 poll_table * wait)
578{
579 irnet_socket * ap = (struct irnet_socket *) file->private_data;
580 unsigned int mask;
581
582 DENTER(FS_TRACE, "(file=0x%X, ap=0x%X)\n",
583 (unsigned int) file, (unsigned int) ap);
584
585 mask = POLLOUT | POLLWRNORM;
586 DABORT(ap == NULL, mask, FS_ERROR, "ap is NULL !!!\n");
587
588
589 if(!ap->ppp_open)
590 mask |= irnet_ctrl_poll(ap, file, wait);
591
592 DEXIT(FS_TRACE, " - mask=0x%X\n", mask);
593 return(mask);
594}
595
596
597
598
599
600
601
602static int
603dev_irnet_ioctl(struct inode * inode,
604 struct file * file,
605 unsigned int cmd,
606 unsigned long arg)
607{
608 irnet_socket * ap = (struct irnet_socket *) file->private_data;
609 int err;
610 int val;
611
612 DENTER(FS_TRACE, "(file=0x%X, ap=0x%X, cmd=0x%X)\n",
613 (unsigned int) file, (unsigned int) ap, cmd);
614
615
616 DASSERT(ap != NULL, -ENXIO, PPP_ERROR, "ap is NULL...\n");
617#ifdef SECURE_DEVIRNET
618 if(!capable(CAP_NET_ADMIN))
619 return -EPERM;
620#endif
621
622 err = -EFAULT;
623 switch(cmd)
624 {
625
626 case TIOCSETD:
627 if(get_user(val, (int *) arg))
628 break;
629 if((val == N_SYNC_PPP) || (val == N_PPP))
630 {
631 DEBUG(FS_INFO, "Entering PPP discipline.\n");
632
633 err = ppp_register_channel(&ap->chan);
634 if(err == 0)
635 {
636
637 ap->ppp_open = 1;
638
639 DEBUG(FS_INFO, "Trying to establish a connection.\n");
640
641 irda_irnet_connect(ap);
642 }
643 else
644 DERROR(FS_ERROR, "Can't setup PPP channel...\n");
645 }
646 else
647 {
648
649 DEBUG(FS_INFO, "Exiting PPP discipline.\n");
650
651 if(ap->ppp_open)
652 ppp_unregister_channel(&ap->chan);
653 else
654 DERROR(FS_ERROR, "Channel not registered !\n");
655 ap->ppp_open = 0;
656 err = 0;
657 }
658 break;
659
660
661 case PPPIOCGCHAN:
662 if(!ap->ppp_open)
663 break;
664 if(put_user(ppp_channel_index(&ap->chan), (int *) arg))
665 break;
666 DEBUG(FS_INFO, "Query channel.\n");
667 err = 0;
668 break;
669 case PPPIOCGUNIT:
670 if(!ap->ppp_open)
671 break;
672 if(put_user(ppp_unit_number(&ap->chan), (int *) arg))
673 break;
674 DEBUG(FS_INFO, "Query unit number.\n");
675 err = 0;
676 break;
677
678
679
680
681 case PPPIOCGFLAGS:
682 case PPPIOCSFLAGS:
683 case PPPIOCGASYNCMAP:
684 case PPPIOCSASYNCMAP:
685 case PPPIOCGRASYNCMAP:
686 case PPPIOCSRASYNCMAP:
687 case PPPIOCGXASYNCMAP:
688 case PPPIOCSXASYNCMAP:
689 case PPPIOCGMRU:
690 case PPPIOCSMRU:
691 DEBUG(FS_INFO, "Standard PPP ioctl.\n");
692 if(!capable(CAP_NET_ADMIN))
693 err = -EPERM;
694 else
695 err = ppp_irnet_ioctl(&ap->chan, cmd, arg);
696 break;
697
698
699
700 case TCGETS:
701 DEBUG(FS_INFO, "Get termios.\n");
702 if(kernel_termios_to_user_termios((struct termios *)arg, &ap->termios))
703 break;
704 err = 0;
705 break;
706
707 case TCSETSF:
708 DEBUG(FS_INFO, "Set termios.\n");
709 if(user_termios_to_kernel_termios(&ap->termios, (struct termios *) arg))
710 break;
711 err = 0;
712 break;
713
714
715 case TIOCMBIS:
716 case TIOCMBIC:
717
718 case TIOCEXCL:
719 case TIOCNXCL:
720 DEBUG(FS_INFO, "TTY compatibility.\n");
721 err = 0;
722 break;
723
724 case TCGETA:
725 DEBUG(FS_INFO, "TCGETA\n");
726 break;
727
728 case TCFLSH:
729 DEBUG(FS_INFO, "TCFLSH\n");
730
731
732
733#ifdef FLUSH_TO_PPP
734 ppp_output_wakeup(&ap->chan);
735#endif
736 err = 0;
737 break;
738
739 case FIONREAD:
740 DEBUG(FS_INFO, "FIONREAD\n");
741 val = 0;
742 if(put_user(val, (int *) arg))
743 break;
744 err = 0;
745 break;
746
747 default:
748 DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd);
749 err = -ENOIOCTLCMD;
750 }
751
752 DEXIT(FS_TRACE, " - err = 0x%X\n", err);
753 return err;
754}
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769static inline struct sk_buff *
770irnet_prepare_skb(irnet_socket * ap,
771 struct sk_buff * skb)
772{
773 unsigned char * data;
774 int proto;
775 int islcp;
776 int needaddr;
777
778 DENTER(PPP_TRACE, "(ap=0x%X, skb=0x%X)\n",
779 (unsigned int) ap, (unsigned int) skb);
780
781
782 data = skb->data;
783 proto = (data[0] << 8) + data[1];
784
785
786
787
788 islcp = (proto == PPP_LCP) && (1 <= data[2]) && (data[2] <= 7);
789
790
791 if((data[0] == 0) && (ap->flags & SC_COMP_PROT) && (!islcp))
792 skb_pull(skb,1);
793
794
795 needaddr = 2*((ap->flags & SC_COMP_AC) == 0 || islcp);
796
797
798 if((skb_headroom(skb) < (ap->max_header_size + needaddr)) ||
799 (skb_shared(skb)))
800 {
801 struct sk_buff * new_skb;
802
803 DEBUG(PPP_INFO, "Reallocating skb\n");
804
805
806 new_skb = skb_realloc_headroom(skb, ap->max_header_size + needaddr);
807
808
809 dev_kfree_skb(skb);
810
811
812 DABORT(new_skb == NULL, NULL, PPP_ERROR, "Could not realloc skb\n");
813
814
815 skb = new_skb;
816 }
817
818
819 if(needaddr)
820 {
821 skb_push(skb, 2);
822 skb->data[0] = PPP_ALLSTATIONS;
823 skb->data[1] = PPP_UI;
824 }
825
826 DEXIT(PPP_TRACE, "\n");
827
828 return skb;
829}
830
831
832
833
834
835
836
837
838
839static int
840ppp_irnet_send(struct ppp_channel * chan,
841 struct sk_buff * skb)
842{
843 irnet_socket * self = (struct irnet_socket *) chan->private;
844 int ret;
845
846 DENTER(PPP_TRACE, "(channel=0x%X, ap/self=0x%X)\n",
847 (unsigned int) chan, (unsigned int) self);
848
849
850 DASSERT(self != NULL, 0, PPP_ERROR, "Self is NULL !!!\n");
851
852
853 if(!(test_bit(0, &self->ttp_open)))
854 {
855#ifdef CONNECT_IN_SEND
856
857
858
859
860 irda_irnet_connect(self);
861#endif
862
863 DEBUG(PPP_INFO, "IrTTP not ready ! (%d-%d)\n",
864 self->ttp_open, self->ttp_connect);
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885#ifdef BLOCK_WHEN_CONNECT
886
887 if(test_bit(0, &self->ttp_connect))
888 {
889
890 return 0;
891 }
892#endif
893
894
895 dev_kfree_skb(skb);
896 return 1;
897 }
898
899
900 if(self->tx_flow != FLOW_START)
901 DRETURN(0, PPP_INFO, "IrTTP queue full (%d skbs)...\n",
902 skb_queue_len(&self->tsap->tx_queue));
903
904
905 skb = irnet_prepare_skb(self, skb);
906 DABORT(skb == NULL, 1, PPP_ERROR, "Prepare skb for Tx failed.\n");
907
908
909 ret = irttp_data_request(self->tsap, skb);
910 if(ret < 0)
911 {
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927 DERROR(PPP_ERROR, "IrTTP doesn't like this packet !!! (0x%X)\n", ret);
928 dev_kfree_skb(skb);
929 }
930
931 DEXIT(PPP_TRACE, "\n");
932 return 1;
933}
934
935
936
937
938
939
940static int
941ppp_irnet_ioctl(struct ppp_channel * chan,
942 unsigned int cmd,
943 unsigned long arg)
944{
945 irnet_socket * ap = (struct irnet_socket *) chan->private;
946 int err;
947 int val;
948 u32 accm[8];
949
950 DENTER(PPP_TRACE, "(channel=0x%X, ap=0x%X, cmd=0x%X)\n",
951 (unsigned int) chan, (unsigned int) ap, cmd);
952
953
954 DASSERT(ap != NULL, -ENXIO, PPP_ERROR, "ap is NULL...\n");
955
956 err = -EFAULT;
957 switch(cmd)
958 {
959
960 case PPPIOCGFLAGS:
961 val = ap->flags | ap->rbits;
962 if(put_user(val, (int *) arg))
963 break;
964 err = 0;
965 break;
966 case PPPIOCSFLAGS:
967 if(get_user(val, (int *) arg))
968 break;
969 ap->flags = val & ~SC_RCV_BITS;
970 ap->rbits = val & SC_RCV_BITS;
971 err = 0;
972 break;
973
974
975 case PPPIOCGASYNCMAP:
976 if(put_user(ap->xaccm[0], (u32 *) arg))
977 break;
978 err = 0;
979 break;
980 case PPPIOCSASYNCMAP:
981 if(get_user(ap->xaccm[0], (u32 *) arg))
982 break;
983 err = 0;
984 break;
985 case PPPIOCGRASYNCMAP:
986 if(put_user(ap->raccm, (u32 *) arg))
987 break;
988 err = 0;
989 break;
990 case PPPIOCSRASYNCMAP:
991 if(get_user(ap->raccm, (u32 *) arg))
992 break;
993 err = 0;
994 break;
995 case PPPIOCGXASYNCMAP:
996 if(copy_to_user((void *) arg, ap->xaccm, sizeof(ap->xaccm)))
997 break;
998 err = 0;
999 break;
1000 case PPPIOCSXASYNCMAP:
1001 if(copy_from_user(accm, (void *) arg, sizeof(accm)))
1002 break;
1003 accm[2] &= ~0x40000000U;
1004 accm[3] |= 0x60000000U;
1005 memcpy(ap->xaccm, accm, sizeof(ap->xaccm));
1006 err = 0;
1007 break;
1008
1009
1010 case PPPIOCGMRU:
1011 if(put_user(ap->mru, (int *) arg))
1012 break;
1013 err = 0;
1014 break;
1015 case PPPIOCSMRU:
1016 if(get_user(val, (int *) arg))
1017 break;
1018 if(val < PPP_MRU)
1019 val = PPP_MRU;
1020 ap->mru = val;
1021 err = 0;
1022 break;
1023
1024 default:
1025 DEBUG(PPP_INFO, "Unsupported ioctl (0x%X)\n", cmd);
1026 err = -ENOIOCTLCMD;
1027 }
1028
1029 DEXIT(PPP_TRACE, " - err = 0x%X\n", err);
1030 return err;
1031}
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043int
1044ppp_irnet_init(void)
1045{
1046 int err = 0;
1047
1048 DENTER(MODULE_TRACE, "()\n");
1049
1050
1051 err = misc_register(&irnet_misc_device);
1052
1053 DEXIT(MODULE_TRACE, "\n");
1054 return err;
1055}
1056
1057
1058
1059
1060
1061void
1062ppp_irnet_cleanup(void)
1063{
1064 DENTER(MODULE_TRACE, "()\n");
1065
1066
1067 misc_deregister(&irnet_misc_device);
1068
1069 DEXIT(MODULE_TRACE, "\n");
1070}
1071
1072#ifdef MODULE
1073
1074
1075
1076
1077int
1078init_module(void)
1079{
1080 int err;
1081
1082
1083 err = irda_irnet_init();
1084 if(!err)
1085 err = ppp_irnet_init();
1086 return err;
1087}
1088
1089
1090
1091
1092
1093void
1094cleanup_module(void)
1095{
1096 irda_irnet_cleanup();
1097 return ppp_irnet_cleanup();
1098}
1099#endif
1100MODULE_LICENSE("GPL");
1101