Rev 2556 | Rev 2601 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2556 | Rev 2557 | ||
|---|---|---|---|
| Line 67... | Line 67... | ||
| 67 | * @param method Method to be decided. |
67 | * @param method Method to be decided. |
| 68 | * |
68 | * |
| 69 | * @return Return 1 if the method is a system method. |
69 | * @return Return 1 if the method is a system method. |
| 70 | * Otherwise return 0. |
70 | * Otherwise return 0. |
| 71 | */ |
71 | */ |
| 72 | static inline int is_system_method(unative_t method) |
72 | static inline int method_is_system(unative_t method) |
| 73 | { |
73 | { |
| 74 | if (method <= IPC_M_LAST_SYSTEM) |
74 | if (method <= IPC_M_LAST_SYSTEM) |
| 75 | return 1; |
75 | return 1; |
| 76 | return 0; |
76 | return 0; |
| 77 | } |
77 | } |
| Line 84... | Line 84... | ||
| 84 | * @param method Method to be decided. |
84 | * @param method Method to be decided. |
| 85 | * |
85 | * |
| 86 | * @return Return 1 if the method is forwardable. |
86 | * @return Return 1 if the method is forwardable. |
| 87 | * Otherwise return 0. |
87 | * Otherwise return 0. |
| 88 | */ |
88 | */ |
| 89 | static inline int is_forwardable(unative_t method) |
89 | static inline int method_is_forwardable(unative_t method) |
| 90 | { |
90 | { |
| 91 | switch (method) { |
91 | switch (method) { |
| 92 | case IPC_M_PHONE_HUNGUP: |
92 | case IPC_M_PHONE_HUNGUP: |
| 93 | case IPC_M_AS_AREA_SEND: |
- | |
| 94 | case IPC_M_AS_AREA_RECV: |
- | |
| 95 | case IPC_M_DATA_SEND: |
- | |
| 96 | /* This message is meant only for the original recipient. */ |
93 | /* This message is meant only for the original recipient. */ |
| 97 | return 0; |
94 | return 0; |
| 98 | default: |
95 | default: |
| 99 | return 1; |
96 | return 1; |
| 100 | } |
97 | } |
| 101 | } |
98 | } |
| 102 | 99 | ||
| - | 100 | /** Decide if the message with this method is immutable on forward. |
|
| - | 101 | * |
|
| - | 102 | * - some system messages may be forwarded, for some of them |
|
| - | 103 | * it is useless |
|
| - | 104 | * |
|
| - | 105 | * @param method Method to be decided. |
|
| - | 106 | * |
|
| - | 107 | * @return Return 1 if the method is immutable on forward. |
|
| - | 108 | * Otherwise return 0. |
|
| - | 109 | */ |
|
| - | 110 | static inline int method_is_immutable(unative_t method) |
|
| - | 111 | { |
|
| - | 112 | switch (method) { |
|
| - | 113 | case IPC_M_AS_AREA_SEND: |
|
| - | 114 | case IPC_M_AS_AREA_RECV: |
|
| - | 115 | case IPC_M_DATA_SEND: |
|
| - | 116 | return 1; |
|
| - | 117 | break; |
|
| - | 118 | default: |
|
| - | 119 | return 0; |
|
| - | 120 | } |
|
| - | 121 | } |
|
| - | 122 | ||
| 103 | 123 | ||
| 104 | /*********************************************************************** |
124 | /*********************************************************************** |
| 105 | * Functions that preprocess answer before sending it to the recepient. |
125 | * Functions that preprocess answer before sending it to the recepient. |
| 106 | ***********************************************************************/ |
126 | ***********************************************************************/ |
| 107 | 127 | ||
| Line 501... | Line 521... | ||
| 501 | * @return Return 0 on succes, otherwise return an error code. |
521 | * @return Return 0 on succes, otherwise return an error code. |
| 502 | * |
522 | * |
| 503 | * In case the original method is a system method, ARG1 and ARG2 are overwritten |
523 | * In case the original method is a system method, ARG1 and ARG2 are overwritten |
| 504 | * in the forwarded message with the new method and the new arg1, respectively. |
524 | * in the forwarded message with the new method and the new arg1, respectively. |
| 505 | * Otherwise the METHOD and ARG1 are rewritten with the new method and arg1, |
525 | * Otherwise the METHOD and ARG1 are rewritten with the new method and arg1, |
| 506 | * respectively. |
526 | * respectively. Also note there is a set of immutable methods, for which the |
| - | 527 | * new method and argument is not set and these values are ignored. |
|
| 507 | * |
528 | * |
| 508 | * Warning: If implementing non-fast version, make sure that |
529 | * Warning: If implementing non-fast version, make sure that |
| 509 | * ARG3 is not rewritten for certain system IPC |
530 | * ARG3 is not rewritten for certain system IPC |
| 510 | */ |
531 | */ |
| 511 | unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, |
532 | unative_t sys_ipc_forward_fast(unative_t callid, unative_t phoneid, |
| Line 524... | Line 545... | ||
| 524 | IPC_SET_RETVAL(call->data, EFORWARD); |
545 | IPC_SET_RETVAL(call->data, EFORWARD); |
| 525 | ipc_answer(&TASK->answerbox, call); |
546 | ipc_answer(&TASK->answerbox, call); |
| 526 | return ENOENT; |
547 | return ENOENT; |
| 527 | }); |
548 | }); |
| 528 | 549 | ||
| 529 | if (!is_forwardable(IPC_GET_METHOD(call->data))) { |
550 | if (!method_is_forwardable(IPC_GET_METHOD(call->data))) { |
| 530 | IPC_SET_RETVAL(call->data, EFORWARD); |
551 | IPC_SET_RETVAL(call->data, EFORWARD); |
| 531 | ipc_answer(&TASK->answerbox, call); |
552 | ipc_answer(&TASK->answerbox, call); |
| 532 | return EPERM; |
553 | return EPERM; |
| 533 | } |
554 | } |
| 534 | 555 | ||
| - | 556 | /* |
|
| 535 | /* Userspace is not allowed to change method of system methods |
557 | * Userspace is not allowed to change method of system methods on |
| 536 | * on forward, allow changing ARG1 and ARG2 by means of method and arg1 |
558 | * forward, allow changing ARG1 and ARG2 by means of method and arg1. |
| - | 559 | * If the method is immutable, don't change anything. |
|
| 537 | */ |
560 | */ |
| - | 561 | if (!method_is_immutable(IPC_GET_METHOD(call->data))) { |
|
| 538 | if (is_system_method(IPC_GET_METHOD(call->data))) { |
562 | if (method_is_system(IPC_GET_METHOD(call->data))) { |
| 539 | if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) |
563 | if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME) |
| 540 | phone_dealloc(IPC_GET_ARG3(call->data)); |
564 | phone_dealloc(IPC_GET_ARG3(call->data)); |
| 541 | 565 | ||
| 542 | IPC_SET_ARG1(call->data, method); |
566 | IPC_SET_ARG1(call->data, method); |
| 543 | IPC_SET_ARG2(call->data, arg1); |
567 | IPC_SET_ARG2(call->data, arg1); |
| 544 | } else { |
568 | } else { |
| 545 | IPC_SET_METHOD(call->data, method); |
569 | IPC_SET_METHOD(call->data, method); |
| 546 | IPC_SET_ARG1(call->data, arg1); |
570 | IPC_SET_ARG1(call->data, arg1); |
| - | 571 | } |
|
| 547 | } |
572 | } |
| 548 | 573 | ||
| 549 | return ipc_forward(call, phone, &TASK->answerbox); |
574 | return ipc_forward(call, phone, &TASK->answerbox); |
| 550 | } |
575 | } |
| 551 | 576 | ||