Lines Matching +full:0 +full:x25

33 #define pr_fmt(fmt) "X25: " fmt
57 #include <net/x25.h>
65 int sysctl_x25_forward = 0;
93 rc = 0; in x25_parse_address_block()
98 needed = 1 + ((len >> 4) + (len & 0x0f) + 1) / 2; in x25_parse_address_block()
110 *called_addr->x25_addr = 0; in x25_parse_address_block()
111 *calling_addr->x25_addr = 0; in x25_parse_address_block()
124 called_len = (*p >> 0) & 0x0F; in x25_addr_ntoa()
125 calling_len = (*p >> 4) & 0x0F; in x25_addr_ntoa()
131 for (i = 0; i < (called_len + calling_len); i++) { in x25_addr_ntoa()
133 if (i % 2 != 0) { in x25_addr_ntoa()
134 *called++ = ((*p >> 0) & 0x0F) + '0'; in x25_addr_ntoa()
137 *called++ = ((*p >> 4) & 0x0F) + '0'; in x25_addr_ntoa()
140 if (i % 2 != 0) { in x25_addr_ntoa()
141 *calling++ = ((*p >> 0) & 0x0F) + '0'; in x25_addr_ntoa()
144 *calling++ = ((*p >> 4) & 0x0F) + '0'; in x25_addr_ntoa()
149 *called = *calling = '\0'; in x25_addr_ntoa()
167 *p++ = (calling_len << 4) | (called_len << 0); in x25_addr_aton()
169 for (i = 0; i < (called_len + calling_len); i++) { in x25_addr_aton()
171 if (i % 2 != 0) { in x25_addr_aton()
172 *p |= (*called++ - '0') << 0; in x25_addr_aton()
175 *p = 0x00; in x25_addr_aton()
176 *p |= (*called++ - '0') << 4; in x25_addr_aton()
179 if (i % 2 != 0) { in x25_addr_aton()
180 *p |= (*calling++ - '0') << 0; in x25_addr_aton()
183 *p = 0x00; in x25_addr_aton()
184 *p |= (*calling++ - '0') << 4; in x25_addr_aton()
213 x25_disconnect(s, ENETUNREACH, 0, 0); in x25_kill_by_device()
293 if (x25_sk(s)->cudmatchlength > 0 && in x25_find_listener()
297 x25_sk(s)->cudmatchlength)) == 0) { in x25_find_listener()
353 lci = 0; in x25_new_lci()
455 rc = 0; in x25_setsockopt()
476 if (len < 0) in x25_getsockopt()
484 rc = copy_to_user(optval, &val, len) ? -EFAULT : 0; in x25_getsockopt()
496 memset(&x25_sk(sk)->dest_addr, 0, X25_ADDR_LEN); in x25_listen()
499 rc = 0; in x25_listen()
507 .name = "X25",
514 struct x25_sock *x25; in x25_alloc_socket() local
522 x25 = x25_sk(sk); in x25_alloc_socket()
523 skb_queue_head_init(&x25->ack_queue); in x25_alloc_socket()
524 skb_queue_head_init(&x25->fragment_queue); in x25_alloc_socket()
525 skb_queue_head_init(&x25->interrupt_in_queue); in x25_alloc_socket()
526 skb_queue_head_init(&x25->interrupt_out_queue); in x25_alloc_socket()
535 struct x25_sock *x25; in x25_create() local
553 x25 = x25_sk(sk); in x25_create()
563 x25->t21 = sysctl_x25_call_request_timeout; in x25_create()
564 x25->t22 = sysctl_x25_reset_request_timeout; in x25_create()
565 x25->t23 = sysctl_x25_clear_request_timeout; in x25_create()
566 x25->t2 = sysctl_x25_ack_holdback_timeout; in x25_create()
567 x25->state = X25_STATE_0; in x25_create()
568 x25->cudmatchlength = 0; in x25_create()
569 set_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); /* normally no cud */ in x25_create()
572 x25->facilities.winsize_in = X25_DEFAULT_WINDOW_SIZE; in x25_create()
573 x25->facilities.winsize_out = X25_DEFAULT_WINDOW_SIZE; in x25_create()
574 x25->facilities.pacsize_in = X25_DEFAULT_PACKET_SIZE; in x25_create()
575 x25->facilities.pacsize_out = X25_DEFAULT_PACKET_SIZE; in x25_create()
576 x25->facilities.throughput = 0; /* by default don't negotiate in x25_create()
578 x25->facilities.reverse = X25_DEFAULT_REVERSE; in x25_create()
579 x25->dte_facilities.calling_len = 0; in x25_create()
580 x25->dte_facilities.called_len = 0; in x25_create()
581 memset(x25->dte_facilities.called_ae, '\0', in x25_create()
582 sizeof(x25->dte_facilities.called_ae)); in x25_create()
583 memset(x25->dte_facilities.calling_ae, '\0', in x25_create()
584 sizeof(x25->dte_facilities.calling_ae)); in x25_create()
586 rc = 0; in x25_create()
594 struct x25_sock *x25, *ox25; in x25_make_new() local
599 if ((sk = x25_alloc_socket(sock_net(osk), 0)) == NULL) in x25_make_new()
602 x25 = x25_sk(sk); in x25_make_new()
614 x25->t21 = ox25->t21; in x25_make_new()
615 x25->t22 = ox25->t22; in x25_make_new()
616 x25->t23 = ox25->t23; in x25_make_new()
617 x25->t2 = ox25->t2; in x25_make_new()
618 x25->flags = ox25->flags; in x25_make_new()
619 x25->facilities = ox25->facilities; in x25_make_new()
620 x25->dte_facilities = ox25->dte_facilities; in x25_make_new()
621 x25->cudmatchlength = ox25->cudmatchlength; in x25_make_new()
623 clear_bit(X25_INTERRUPT_FLAG, &x25->flags); in x25_make_new()
632 struct x25_sock *x25; in x25_release() local
635 return 0; in x25_release()
637 x25 = x25_sk(sk); in x25_release()
641 switch (x25->state) { in x25_release()
645 x25_disconnect(sk, 0, 0, 0); in x25_release()
655 x25->state = X25_STATE_2; in x25_release()
665 x25_disconnect(sk, 0, 0, 0); in x25_release()
674 return 0; in x25_release()
681 int len, i, rc = 0; in x25_bind()
694 for (i = 0; i < len; i++) { in x25_bind()
732 rc = 0; in x25_wait_for_connection_establishment()
749 struct x25_sock *x25 = x25_sk(sk); in x25_connect() local
752 int rc = 0; in x25_connect()
788 x25->neighbour = x25_get_neigh(rt->dev); in x25_connect()
789 if (!x25->neighbour) in x25_connect()
792 x25_limit_facilities(&x25->facilities, x25->neighbour); in x25_connect()
794 x25->lci = x25_new_lci(x25->neighbour); in x25_connect()
795 if (!x25->lci) in x25_connect()
802 if (!strcmp(x25->source_addr.x25_addr, null_x25_address.x25_addr)) in x25_connect()
803 memset(&x25->source_addr, '\0', X25_ADDR_LEN); in x25_connect()
805 x25->dest_addr = addr->sx25_addr; in x25_connect()
811 x25->state = X25_STATE_1; in x25_connect()
828 rc = 0; in x25_connect()
830 if (rc && x25->neighbour) { in x25_connect()
832 x25_neigh_put(x25->neighbour); in x25_connect()
833 x25->neighbour = NULL; in x25_connect()
835 x25->state = X25_STATE_0; in x25_connect()
847 int rc = 0; in x25_wait_for_data()
860 rc = 0; in x25_wait_for_data()
908 rc = 0; in x25_accept()
920 struct x25_sock *x25 = x25_sk(sk); in x25_getname() local
921 int rc = 0; in x25_getname()
928 sx25->sx25_addr = x25->dest_addr; in x25_getname()
930 sx25->sx25_addr = x25->source_addr; in x25_getname()
962 if (addr_len <= 0) in x25_rx_call_request()
975 len = skb->data[0] + 1; in x25_rx_call_request()
1010 x25_forward_call(&dest_addr, nb, skb, lci) > 0) in x25_rx_call_request()
1097 rc = 0; in x25_rx_call_request()
1098 x25_transmit_clear_request(nb, lci, 0x01); in x25_rx_call_request()
1105 struct x25_sock *x25 = x25_sk(sk); in x25_sendmsg() local
1112 int qbit = 0, rc = -EINVAL; in x25_sendmsg()
1128 send_sig(SIGPIPE, current, 0); in x25_sendmsg()
1133 if (!x25->neighbour) in x25_sendmsg()
1142 if (strcmp(x25->dest_addr.x25_addr, sx25.sx25_addr.x25_addr)) in x25_sendmsg()
1158 sx25.sx25_addr = x25->dest_addr; in x25_sendmsg()
1202 if (test_bit(X25_Q_BIT_FLAG, &x25->flags)) { in x25_sendmsg()
1206 qbit = skb->data[0]; in x25_sendmsg()
1216 if (x25->neighbour->extended) { in x25_sendmsg()
1218 *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ; in x25_sendmsg()
1219 *asmptr++ = (x25->lci >> 0) & 0xFF; in x25_sendmsg()
1223 *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ; in x25_sendmsg()
1224 *asmptr++ = (x25->lci >> 0) & 0xFF; in x25_sendmsg()
1228 if (x25->neighbour->extended) { in x25_sendmsg()
1231 *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_EXTSEQ; in x25_sendmsg()
1232 *asmptr++ = (x25->lci >> 0) & 0xFF; in x25_sendmsg()
1238 *asmptr++ = ((x25->lci >> 8) & 0x0F) | X25_GFI_STDSEQ; in x25_sendmsg()
1239 *asmptr++ = (x25->lci >> 0) & 0xFF; in x25_sendmsg()
1244 skb->data[0] |= X25_Q_BIT; in x25_sendmsg()
1255 skb_queue_tail(&x25->interrupt_out_queue, skb); in x25_sendmsg()
1259 if (rc < 0) in x25_sendmsg()
1261 else if (test_bit(X25_Q_BIT_FLAG, &x25->flags)) in x25_sendmsg()
1280 struct x25_sock *x25 = x25_sk(sk); in x25_recvmsg() local
1290 if (x25->neighbour == NULL) in x25_recvmsg()
1293 header_len = x25->neighbour->extended ? in x25_recvmsg()
1306 !skb_peek(&x25->interrupt_in_queue)) in x25_recvmsg()
1309 skb = skb_dequeue(&x25->interrupt_in_queue); in x25_recvmsg()
1319 if (test_bit(X25_Q_BIT_FLAG, &x25->flags)) { in x25_recvmsg()
1321 *asmptr = 0x00; in x25_recvmsg()
1337 qbit = (skb->data[0] & X25_Q_BIT) == X25_Q_BIT; in x25_recvmsg()
1341 if (test_bit(X25_Q_BIT_FLAG, &x25->flags)) { in x25_recvmsg()
1358 rc = skb_copy_datagram_msg(skb, 0, msg, copied); in x25_recvmsg()
1364 sx25->sx25_addr = x25->dest_addr; in x25_recvmsg()
1381 struct x25_sock *x25 = x25_sk(sk); in x25_ioctl() local
1390 if (amount < 0) in x25_ioctl()
1391 amount = 0; in x25_ioctl()
1398 int amount = 0; in x25_ioctl()
1441 rc = copy_to_user(argp, &x25->facilities, in x25_ioctl()
1442 sizeof(x25->facilities)) in x25_ioctl()
1443 ? -EFAULT : 0; in x25_ioctl()
1468 int out = facilities.throughput & 0xf0; in x25_ioctl()
1469 int in = facilities.throughput & 0x0f; in x25_ioctl()
1473 else if (out < 0x30 || out > 0xD0) in x25_ioctl()
1478 else if (in < 0x03 || in > 0x0D) in x25_ioctl()
1482 (facilities.reverse & 0x81) != 0x81) in x25_ioctl()
1484 x25->facilities = facilities; in x25_ioctl()
1485 rc = 0; in x25_ioctl()
1493 rc = copy_to_user(argp, &x25->dte_facilities, in x25_ioctl()
1494 sizeof(x25->dte_facilities)); in x25_ioctl()
1515 x25->dte_facilities = dtefacs; in x25_ioctl()
1516 rc = 0; in x25_ioctl()
1524 rc = copy_to_user(argp, &x25->calluserdata, in x25_ioctl()
1525 sizeof(x25->calluserdata)) in x25_ioctl()
1526 ? -EFAULT : 0; in x25_ioctl()
1541 x25->calluserdata = calluserdata; in x25_ioctl()
1543 rc = 0; in x25_ioctl()
1549 rc = copy_to_user(argp, &x25->causediag, sizeof(x25->causediag)) in x25_ioctl()
1550 ? -EFAULT : 0; in x25_ioctl()
1561 x25->causediag = causediag; in x25_ioctl()
1563 rc = 0; in x25_ioctl()
1581 x25->cudmatchlength = sub_addr.cudmatchlength; in x25_ioctl()
1582 rc = 0; in x25_ioctl()
1592 clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags); in x25_ioctl()
1593 rc = 0; in x25_ioctl()
1605 if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags)) in x25_ioctl()
1608 x25->state = X25_STATE_3; in x25_ioctl()
1609 rc = 0; in x25_ioctl()
1659 sizeof(*x25_subscr32)) ? -EFAULT : 0; in compat_x25_subscr_ioctl()
1662 if (x25_subscr.extended == 0 || x25_subscr.extended == 1) { in compat_x25_subscr_ioctl()
1663 rc = 0; in compat_x25_subscr_ioctl()
1782 x25_disconnect(s, ENETUNREACH, 0, 0); in x25_kill_by_neigh()
1797 rc = proto_register(&x25_proto, 0); in x25_init()