1/*- 2 * Cronyx-Tau adapter driver for FreeBSD. 3 * Supports PPP/HDLC and Cisco/HDLC protocol in synchronous mode, 4 * and asyncronous channels with full modem control. 5 * Keepalive protocol implemented in both Cisco and PPP modes. 6 * 7 * Copyright (C) 1994-2002 Cronyx Engineering. 8 * Author: Serge Vakulenko, <vak@cronyx.ru> --- 8 unchanged lines hidden (view full) --- 17 * modify and redistribute this software in source and binary forms, 18 * as long as this message is kept with the software, all derivative 19 * works or modified versions. 20 * 21 * Cronyx Id: if_ct.c,v 1.1.2.31 2004/06/23 17:09:13 rik Exp $ 22 */ 23 24#include <sys/cdefs.h> |
25__FBSDID("$FreeBSD: head/sys/dev/ctau/if_ct.c 164033 2006-11-06 13:42:10Z rwatson $"); |
26 27#include <sys/param.h> 28#include <sys/proc.h> 29#include <sys/systm.h> 30#include <sys/kernel.h> 31#include <sys/module.h> 32#include <sys/mbuf.h> 33#include <sys/sockio.h> 34#include <sys/malloc.h> |
35#include <sys/priv.h> |
36#include <sys/socket.h> 37#include <sys/sysctl.h> 38#include <sys/conf.h> 39#include <sys/errno.h> 40#include <sys/tty.h> 41#include <sys/bus.h> 42#include <machine/bus.h> 43#include <sys/rman.h> --- 1252 unchanged lines hidden (view full) --- 1296#ifndef NETGRAPH 1297 case SERIAL_GETPROTO: 1298 strcpy ((char*)data, (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" : 1299 (d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp"); 1300 return 0; 1301 1302 case SERIAL_SETPROTO: 1303 /* Only for superuser! */ |
1304 error = priv_check (td, PRIV_DRIVER); |
1305 if (error) 1306 return error; 1307 if (d->ifp->if_drv_flags & IFF_DRV_RUNNING) 1308 return EBUSY; 1309 if (! strcmp ("cisco", (char*)data)) { 1310 IFP2SP(d->ifp)->pp_flags &= ~(PP_FR); 1311 IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE; 1312 d->ifp->if_flags |= PP_CISCO; --- 11 unchanged lines hidden (view full) --- 1324 if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || 1325 (d->ifp->if_flags & PP_CISCO)) 1326 return EINVAL; 1327 *(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0; 1328 return 0; 1329 1330 case SERIAL_SETKEEPALIVE: 1331 /* Only for superuser! */ |
1332 error = priv_check (td, PRIV_DRIVER); |
1333 if (error) 1334 return error; 1335 if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || 1336 (d->ifp->if_flags & PP_CISCO)) 1337 return EINVAL; 1338 if (*(int*)data) 1339 IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE; 1340 else --- 12 unchanged lines hidden (view full) --- 1353 default: *(char*)data = 'a'; break; 1354 case CFG_B: *(char*)data = 'b'; break; 1355 case CFG_C: *(char*)data = 'c'; break; 1356 } 1357 return 0; 1358 1359 case SERIAL_SETCFG: 1360 /* Only for superuser! */ |
1361 error = priv_check (td, PRIV_DRIVER); |
1362 if (error) 1363 return error; 1364 if (c->mode == M_HDLC) 1365 return EINVAL; 1366 s = splimp (); 1367 CT_LOCK (bd); 1368 switch (*(char*)data) { 1369 case 'a': ct_set_config (c->board, CFG_A); break; --- 61 unchanged lines hidden (view full) --- 1431 opte1->interval[s].oofs = c->interval[s].oofs; 1432 opte1->interval[s].css = c->interval[s].css; 1433 opte1->interval[s].dm = c->interval[s].dm; 1434 } 1435 return 0; 1436 1437 case SERIAL_CLRSTAT: 1438 /* Only for superuser! */ |
1439 error = priv_check (td, PRIV_DRIVER); |
1440 if (error) 1441 return error; 1442 c->rintr = 0; 1443 c->tintr = 0; 1444 c->mintr = 0; 1445 c->ibytes = 0; 1446 c->ipkts = 0; 1447 c->ierrs = 0; --- 6 unchanged lines hidden (view full) --- 1454 return 0; 1455 1456 case SERIAL_GETBAUD: 1457 *(long*)data = ct_get_baud(c); 1458 return 0; 1459 1460 case SERIAL_SETBAUD: 1461 /* Only for superuser! */ |
1462 error = priv_check (td, PRIV_DRIVER); |
1463 if (error) 1464 return error; 1465 s = splimp (); 1466 CT_LOCK (bd); 1467 ct_set_baud (c, *(long*)data); 1468 CT_UNLOCK (bd); 1469 splx (s); 1470 return 0; 1471 1472 case SERIAL_GETLOOP: 1473 *(int*)data = ct_get_loop (c); 1474 return 0; 1475 1476 case SERIAL_SETLOOP: 1477 /* Only for superuser! */ |
1478 error = priv_check (td, PRIV_DRIVER); |
1479 if (error) 1480 return error; 1481 s = splimp (); 1482 CT_LOCK (bd); 1483 ct_set_loop (c, *(int*)data); 1484 CT_UNLOCK (bd); 1485 splx (s); 1486 return 0; 1487 1488 case SERIAL_GETDPLL: 1489 if (c->mode == M_E1 || c->mode == M_G703) 1490 return EINVAL; 1491 *(int*)data = ct_get_dpll (c); 1492 return 0; 1493 1494 case SERIAL_SETDPLL: 1495 /* Only for superuser! */ |
1496 error = priv_check (td, PRIV_DRIVER); |
1497 if (error) 1498 return error; 1499 if (c->mode == M_E1 || c->mode == M_G703) 1500 return EINVAL; 1501 s = splimp (); 1502 CT_LOCK (bd); 1503 ct_set_dpll (c, *(int*)data); 1504 CT_UNLOCK (bd); 1505 splx (s); 1506 return 0; 1507 1508 case SERIAL_GETNRZI: 1509 if (c->mode == M_E1 || c->mode == M_G703) 1510 return EINVAL; 1511 *(int*)data = ct_get_nrzi (c); 1512 return 0; 1513 1514 case SERIAL_SETNRZI: 1515 /* Only for superuser! */ |
1516 error = priv_check (td, PRIV_DRIVER); |
1517 if (error) 1518 return error; 1519 if (c->mode == M_E1 || c->mode == M_G703) 1520 return EINVAL; 1521 s = splimp (); 1522 CT_LOCK (bd); 1523 ct_set_nrzi (c, *(int*)data); 1524 CT_UNLOCK (bd); 1525 splx (s); 1526 return 0; 1527 1528 case SERIAL_GETDEBUG: 1529 *(int*)data = c->debug; 1530 return 0; 1531 1532 case SERIAL_SETDEBUG: 1533 /* Only for superuser! */ |
1534 error = priv_check (td, PRIV_DRIVER); |
1535 if (error) 1536 return error; 1537 c->debug = *(int*)data; 1538#ifndef NETGRAPH 1539 if (d->chan->debug) 1540 d->ifp->if_flags |= IFF_DEBUG; 1541 else 1542 d->ifp->if_flags &= (~IFF_DEBUG); 1543#endif 1544 return 0; 1545 1546 case SERIAL_GETHIGAIN: 1547 if (c->mode != M_E1) 1548 return EINVAL; 1549 *(int*)data = ct_get_higain (c); 1550 return 0; 1551 1552 case SERIAL_SETHIGAIN: 1553 /* Only for superuser! */ |
1554 error = priv_check (td, PRIV_DRIVER); |
1555 if (error) 1556 return error; 1557 s = splimp (); 1558 CT_LOCK (bd); 1559 ct_set_higain (c, *(int*)data); 1560 CT_UNLOCK (bd); 1561 splx (s); 1562 return 0; --- 5 unchanged lines hidden (view full) --- 1568 *(int*)data = c->gopt.phony; 1569 return 0; 1570 1571 case SERIAL_SETPHONY: 1572 CT_DEBUG2 (d, ("ioctl: setphony\n")); 1573 if (c->mode != M_E1) 1574 return EINVAL; 1575 /* Only for superuser! */ |
1576 error = priv_check (td, PRIV_DRIVER); |
1577 if (error) 1578 return error; 1579 s = splimp (); 1580 CT_LOCK (bd); 1581 ct_set_phony (c, *(int*)data); 1582 CT_UNLOCK (bd); 1583 splx (s); 1584 return 0; --- 6 unchanged lines hidden (view full) --- 1591 case GCLK_RCV: *(int*)data = E1CLK_RECEIVE; break; 1592 case GCLK_RCLKO: *(int*)data = c->num ? 1593 E1CLK_RECEIVE_CHAN0 : E1CLK_RECEIVE_CHAN1; break; 1594 } 1595 return 0; 1596 1597 case SERIAL_SETCLK: 1598 /* Only for superuser! */ |
1599 error = priv_check (td, PRIV_DRIVER); |
1600 if (error) 1601 return error; 1602 s = splimp (); 1603 CT_LOCK (bd); 1604 switch (*(int*)data) { 1605 default: ct_set_clk (c, GCLK_INT); break; 1606 case E1CLK_RECEIVE: ct_set_clk (c, GCLK_RCV); break; 1607 case E1CLK_RECEIVE_CHAN0: --- 7 unchanged lines hidden (view full) --- 1615 case SERIAL_GETTIMESLOTS: 1616 if (c->mode != M_E1) 1617 return EINVAL; 1618 *(long*)data = ct_get_ts (c); 1619 return 0; 1620 1621 case SERIAL_SETTIMESLOTS: 1622 /* Only for superuser! */ |
1623 error = priv_check (td, PRIV_DRIVER); |
1624 if (error) 1625 return error; 1626 s = splimp (); 1627 CT_LOCK (bd); 1628 ct_set_ts (c, *(long*)data); 1629 CT_UNLOCK (bd); 1630 splx (s); 1631 return 0; 1632 1633 case SERIAL_GETSUBCHAN: 1634 if (c->mode != M_E1) 1635 return EINVAL; 1636 *(long*)data = ct_get_subchan (c->board); 1637 return 0; 1638 1639 case SERIAL_SETSUBCHAN: 1640 /* Only for superuser! */ |
1641 error = priv_check (td, PRIV_DRIVER); |
1642 if (error) 1643 return error; 1644 s = splimp (); 1645 CT_LOCK (bd); 1646 ct_set_subchan (c->board, *(long*)data); 1647 CT_UNLOCK (bd); 1648 splx (s); 1649 return 0; --- 9 unchanged lines hidden (view full) --- 1659 if (c->mode == M_E1 || c->mode == M_G703) 1660 return EINVAL; 1661 *(int*)data = ct_get_invrxc (c); 1662 return 0; 1663 1664 case SERIAL_SETINVCLK: 1665 case SERIAL_SETINVTCLK: 1666 /* Only for superuser! */ |
1667 error = priv_check (td, PRIV_DRIVER); |
1668 if (error) 1669 return error; 1670 if (c->mode == M_E1 || c->mode == M_G703) 1671 return EINVAL; 1672 s = splimp (); 1673 CT_LOCK (bd); 1674 ct_set_invtxc (c, *(int*)data); 1675 CT_UNLOCK (bd); 1676 splx (s); 1677 return 0; 1678 1679 case SERIAL_SETINVRCLK: 1680 /* Only for superuser! */ |
1681 error = priv_check (td, PRIV_DRIVER); |
1682 if (error) 1683 return error; 1684 if (c->mode == M_E1 || c->mode == M_G703) 1685 return EINVAL; 1686 s = splimp (); 1687 CT_LOCK (bd); 1688 ct_set_invrxc (c, *(int*)data); 1689 CT_UNLOCK (bd); --- 581 unchanged lines hidden --- |