1 /* $NetBSD: fwcontrol.c,v 1.6 2007/11/06 17:02:15 kiyohara Exp $ */
4 * Hidetoshi Shimokawa. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
17 * This product includes software developed by Hidetoshi Shimokawa.
19 * 4. Neither the name of the author nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #if defined(__FreeBSD__)
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD: src/usr.sbin/fwcontrol/fwcontrol.c,v 1.23 2006/10/26 22:33:38 imp Exp $");
41 #include <sys/param.h>
42 #include <sys/malloc.h>
43 #include <sys/types.h>
44 #include <sys/sysctl.h>
45 #include <sys/socket.h>
46 #include <sys/ioctl.h>
47 #include <sys/errno.h>
48 #if defined(__FreeBSD__)
49 #include <sys/eui64.h>
50 #include <dev/firewire/firewire.h>
51 #include <dev/firewire/iec13213.h>
52 #include <dev/firewire/fwphyreg.h>
53 #include <dev/firewire/iec68113.h>
54 #elif defined(__NetBSD__)
56 #include <dev/ieee1394/firewire.h>
57 #include <dev/ieee1394/iec13213.h>
58 #include <dev/ieee1394/fwphyreg.h>
59 #include <dev/ieee1394/iec68113.h>
62 #include <netinet/in.h>
70 #include "fwmethods.h"
72 static void sysctl_set_int(const char *, int);
78 "%s [-prt] [-b pri_req] [-c node] [-d node]"
79 " [-g gap_count] [-l file]\n"
80 "\t[-m EUI64 | hostname] [-o node] [-R filename]"
82 "\t[-s node] [-u bus_num]\n"
83 "\t-b: set PRIORITY_BUDGET register on all supported nodes\n"
84 "\t-c: read configuration ROM\n"
85 "\t-d: hex dump of configuration ROM\n"
86 "\t-g: broadcast gap_count by phy_config packet\n"
87 "\t-l: load and parse hex dump file of configuration ROM\n"
88 "\t-m: set fwmem target\n"
89 "\t-o: send link-on packet to the node\n"
90 "\t-p: dump PHY registers\n"
91 "\t-R: receive DV or MPEG TS stream\n"
93 "\t-S: send DV stream\n"
94 "\t-s: write RESET_START register on the node\n"
95 "\t-t: read topology map\n"
96 "\t-u: specify bus number\n", getprogname());
101 fweui2eui64(const struct fw_eui64
*fweui
, struct eui64
*eui
)
103 *(u_int32_t
*)&(eui
->octet
[0]) = htonl(fweui
->hi
);
104 *(u_int32_t
*)&(eui
->octet
[4]) = htonl(fweui
->lo
);
107 static struct fw_devlstreq
*
110 struct fw_devlstreq
*data
;
112 data
= malloc(sizeof(*data
));
115 if( ioctl(fd
, FW_GDEVLST
, data
) < 0) {
122 str2node(int fd
, const char *nodestr
)
124 struct eui64 eui
, tmpeui
;
125 struct fw_devlstreq
*data
;
133 * Deal with classic node specifications.
135 node
= strtol(nodestr
, &endptr
, 0);
140 * Try to get an eui and match it against available nodes.
142 if (eui64_hostton(nodestr
, &eui
) != 0 && eui64_aton(nodestr
, &eui
) != 0)
147 for (i
= 0; i
< data
->info_len
; i
++) {
148 fweui2eui64(&data
->dev
[i
].eui
, &tmpeui
);
149 if (memcmp(&eui
, &tmpeui
, sizeof(struct eui64
)) == 0) {
150 node
= data
->dev
[i
].dst
;
154 if (i
>= data
->info_len
)
158 if (node
< 0 || node
> 63)
167 struct fw_devlstreq
*data
;
168 struct fw_devinfo
*devinfo
;
170 char addr
[EUI64_SIZ
];
174 printf("%d devices (info_len=%d)\n", data
->n
, data
->info_len
);
175 printf("node EUI64 status\n");
176 for (i
= 0; i
< data
->info_len
; i
++) {
177 devinfo
= &data
->dev
[i
];
178 fweui2eui64(&devinfo
->eui
, &eui
);
179 eui64_ntoa(&eui
, addr
, sizeof(addr
));
180 printf("%4d %s %6d\n",
181 (devinfo
->status
|| i
== 0) ? devinfo
->dst
: -1,
190 read_write_quad(int fd
, struct fw_eui64 eui
, u_int32_t addr_lo
, int readmode
, u_int32_t data
)
192 struct fw_asyreq
*asyreq
;
195 asyreq
= malloc(sizeof(*asyreq
));
198 asyreq
->req
.len
= 16;
200 asyreq
->req
.type
= FWASREQNODE
;
201 asyreq
->pkt
.mode
.rreqq
.dst
= FWLOCALBUS
| node
;
203 asyreq
->req
.type
= FWASREQEUI
;
204 asyreq
->req
.dst
.eui
= eui
;
206 asyreq
->pkt
.mode
.rreqq
.tlrt
= 0;
208 asyreq
->pkt
.mode
.rreqq
.tcode
= FWTCODE_RREQQ
;
210 asyreq
->pkt
.mode
.rreqq
.tcode
= FWTCODE_WREQQ
;
212 asyreq
->pkt
.mode
.rreqq
.dest_hi
= 0xffff;
213 asyreq
->pkt
.mode
.rreqq
.dest_lo
= addr_lo
;
215 qld
= (u_int32_t
*)&asyreq
->pkt
;
217 asyreq
->pkt
.mode
.wreqq
.data
= data
;
219 if (ioctl(fd
, FW_ASYREQ
, asyreq
) < 0) {
231 send_phy_config(int fd
, int root_node
, int gap_count
)
233 struct fw_asyreq
*asyreq
;
235 asyreq
= malloc(sizeof(*asyreq
));
238 asyreq
->req
.len
= 12;
239 asyreq
->req
.type
= FWASREQNODE
;
240 asyreq
->pkt
.mode
.ld
[0] = 0;
241 asyreq
->pkt
.mode
.ld
[1] = 0;
242 asyreq
->pkt
.mode
.common
.tcode
= FWTCODE_PHY
;
244 asyreq
->pkt
.mode
.ld
[1] |= (root_node
& 0x3f) << 24 | 1 << 23;
246 asyreq
->pkt
.mode
.ld
[1] |= 1 << 22 | (gap_count
& 0x3f) << 16;
247 asyreq
->pkt
.mode
.ld
[2] = ~asyreq
->pkt
.mode
.ld
[1];
249 printf("send phy_config root_node=%d gap_count=%d\n",
250 root_node
, gap_count
);
252 if (ioctl(fd
, FW_ASYREQ
, asyreq
) < 0)
258 send_link_on(int fd
, int node
)
260 struct fw_asyreq
*asyreq
;
262 asyreq
= malloc(sizeof(*asyreq
));
265 asyreq
->req
.len
= 12;
266 asyreq
->req
.type
= FWASREQNODE
;
267 asyreq
->pkt
.mode
.common
.tcode
= FWTCODE_PHY
;
268 asyreq
->pkt
.mode
.ld
[1] |= (1 << 30) | ((node
& 0x3f) << 24);
269 asyreq
->pkt
.mode
.ld
[2] = ~asyreq
->pkt
.mode
.ld
[1];
271 if (ioctl(fd
, FW_ASYREQ
, asyreq
) < 0)
277 reset_start(int fd
, int node
)
279 struct fw_asyreq
*asyreq
;
281 asyreq
= malloc(sizeof(*asyreq
));
284 asyreq
->req
.len
= 16;
285 asyreq
->req
.type
= FWASREQNODE
;
286 asyreq
->pkt
.mode
.wreqq
.dst
= FWLOCALBUS
| (node
& 0x3f);
287 asyreq
->pkt
.mode
.wreqq
.tlrt
= 0;
288 asyreq
->pkt
.mode
.wreqq
.tcode
= FWTCODE_WREQQ
;
290 asyreq
->pkt
.mode
.wreqq
.dest_hi
= 0xffff;
291 asyreq
->pkt
.mode
.wreqq
.dest_lo
= 0xf0000000 | RESET_START
;
293 asyreq
->pkt
.mode
.wreqq
.data
= htonl(0x1);
295 if (ioctl(fd
, FW_ASYREQ
, asyreq
) < 0)
301 set_pri_req(int fd
, u_int32_t pri_req
)
303 struct fw_devlstreq
*data
;
304 struct fw_devinfo
*devinfo
;
306 char addr
[EUI64_SIZ
];
307 u_int32_t max
, reg
, old
;
311 #define BUGET_REG 0xf0000218
312 for (i
= 0; i
< data
->info_len
; i
++) {
313 devinfo
= &data
->dev
[i
];
314 if (!devinfo
->status
)
316 reg
= read_write_quad(fd
, devinfo
->eui
, BUGET_REG
, 1, 0);
317 fweui2eui64(&devinfo
->eui
, &eui
);
318 eui64_ntoa(&eui
, addr
, sizeof(addr
));
319 printf("%d %s, %08x",
320 devinfo
->dst
, addr
, reg
);
323 max
= (reg
& 0x3f00) >> 8;
326 printf(" 0x%x -> 0x%x\n", old
, pri_req
);
327 read_write_quad(fd
, devinfo
->eui
, BUGET_REG
, 0, pri_req
);
336 parse_bus_info_block(u_int32_t
*p
)
338 char addr
[EUI64_SIZ
];
342 bi
= (struct bus_info
*)p
;
343 fweui2eui64(&bi
->eui64
, &eui
);
344 eui64_ntoa(&eui
, addr
, sizeof(addr
));
345 printf("bus_name: 0x%04x\n"
346 "irmc:%d cmc:%d isc:%d bmc:%d pmc:%d\n"
347 "cyc_clk_acc:%d max_rec:%d max_rom:%d\n"
348 "generation:%d link_spd:%d\n"
351 bi
->irmc
, bi
->cmc
, bi
->isc
, bi
->bmc
, bi
->pmc
,
352 bi
->cyc_clk_acc
, bi
->max_rec
, bi
->max_rom
,
353 bi
->generation
, bi
->link_spd
,
358 get_crom(int fd
, int node
, void *crom_buf
, int len
)
360 struct fw_crom_buf buf
;
362 struct fw_devlstreq
*data
;
366 for (i
= 0; i
< data
->info_len
; i
++) {
367 if (data
->dev
[i
].dst
== node
&& data
->dev
[i
].eui
.lo
!= 0)
370 if (i
== data
->info_len
)
371 errx(1, "no such node %d.", node
);
373 buf
.eui
= data
->dev
[i
].eui
;
378 bzero(crom_buf
, len
);
379 if ((error
= ioctl(fd
, FW_GCROM
, &buf
)) < 0) {
387 show_crom(u_int32_t
*crom_buf
)
390 struct crom_context cc
;
393 static const char *key_types
= "ICLD";
395 struct csrdirectory
*dir
;
399 printf("first quad: 0x%08x ", *crom_buf
);
400 if (crom_buf
[0] == 0) {
401 printf("(Invalid Configuration ROM)\n");
404 hdr
= (struct csrhdr
*)crom_buf
;
405 if (hdr
->info_len
== 1) {
407 reg
= (struct csrreg
*)hdr
;
408 printf("verndor ID: 0x%06x\n", reg
->val
);
411 printf("info_len=%d crc_len=%d crc=0x%04x",
412 hdr
->info_len
, hdr
->crc_len
, hdr
->crc
);
413 crc
= crom_crc(crom_buf
+1, hdr
->crc_len
);
418 parse_bus_info_block(crom_buf
+1);
420 crom_init_context(&cc
, crom_buf
);
421 dir
= cc
.stack
[0].dir
;
423 printf("no root directory - giving up\n");
426 printf("root_directory: len=0x%04x(%d) crc=0x%04x",
427 dir
->crc_len
, dir
->crc_len
, dir
->crc
);
428 crc
= crom_crc((u_int32_t
*)&dir
->entry
[0], dir
->crc_len
);
433 if (dir
->crc_len
< 1)
435 while (cc
.depth
>= 0) {
436 desc
= crom_desc(&cc
, info
, sizeof(info
));
438 for (i
= 0; i
< cc
.depth
; i
++)
440 printf("%02x(%c:%02x) %06x %s: %s\n",
442 key_types
[(reg
->key
& CSRTYPE_MASK
)>>6],
443 reg
->key
& CSRKEY_MASK
, reg
->val
,
449 #define DUMP_FORMAT "%08x %08x %08x %08x %08x %08x %08x %08x\n"
452 dump_crom(u_int32_t
*p
)
456 for (i
= 0; i
< len
/(4*8); i
++) {
458 p
[0], p
[1], p
[2], p
[3], p
[4], p
[5], p
[6], p
[7]);
464 load_crom(char *filename
, u_int32_t
*p
)
469 if ((file
= fopen(filename
, "r")) == NULL
)
471 for (i
= 0; i
< len
/(4*8); i
++) {
472 fscanf(file
, DUMP_FORMAT
,
473 p
, p
+1, p
+2, p
+3, p
+4, p
+5, p
+6, p
+7);
480 show_topology_map(int fd
)
482 struct fw_topology_map
*tmap
;
483 union fw_self_id sid
;
485 static const char *port_status
[] = {" ", "-", "P", "C"};
486 static const char *pwr_class
[] = {" 0W", "15W", "30W", "45W",
487 "-1W", "-2W", "-5W", "-9W"};
488 static const char *speed
[] = {"S100", "S200", "S400", "S800"};
489 tmap
= malloc(sizeof(*tmap
));
492 if (ioctl(fd
, FW_GTPMAP
, tmap
) < 0) {
495 printf("crc_len: %d generation:%d node_count:%d sid_count:%d\n",
496 tmap
->crc_len
, tmap
->generation
,
497 tmap
->node_count
, tmap
->self_id_count
);
498 printf("id link gap_cnt speed delay cIRM power port0 port1 port2"
500 for (i
= 0; i
< tmap
->crc_len
- 2; i
++) {
501 sid
= tmap
->self_id
[i
];
503 printf("%02d sequel packet\n", sid
.p0
.phy_id
);
506 printf("%02d %2d %2d %4s %d %d %3s"
511 speed
[sid
.p0
.phy_speed
],
514 pwr_class
[sid
.p0
.power_class
],
515 port_status
[sid
.p0
.port0
],
516 port_status
[sid
.p0
.port1
],
517 port_status
[sid
.p0
.port2
],
518 sid
.p0
.initiated_reset
,
526 read_phy_registers(int fd
, u_int8_t
*buf
, int offset
, int len
)
528 struct fw_reg_req_t reg
;
531 for (i
= 0; i
< len
; i
++) {
532 reg
.addr
= offset
+ i
;
533 if (ioctl(fd
, FWOHCI_RDPHYREG
, ®
) < 0)
535 buf
[i
] = (u_int8_t
) reg
.data
;
536 printf("0x%02x ", reg
.data
);
542 read_phy_page(int fd
, u_int8_t
*buf
, int page
, int port
)
544 struct fw_reg_req_t reg
;
547 reg
.data
= ((page
& 7) << 5) | (port
& 0xf);
548 if (ioctl(fd
, FWOHCI_WRPHYREG
, ®
) < 0)
550 read_phy_registers(fd
, buf
, 8, 8);
554 dump_phy_registers(int fd
)
556 struct phyreg_base b
;
557 struct phyreg_page0 p
;
558 struct phyreg_page1 v
;
561 printf("=== base register ===\n");
562 read_phy_registers(fd
, (u_int8_t
*)&b
, 0, 8);
564 "Physical_ID:%d R:%d CPS:%d\n"
565 "RHB:%d IBR:%d Gap_Count:%d\n"
566 "Extended:%d Num_Ports:%d\n"
567 "PHY_Speed:%d Delay:%d\n"
568 "LCtrl:%d C:%d Jitter:%d Pwr_Class:%d\n"
569 "WDIE:%d ISBR:%d CTOI:%d CPSI:%d STOI:%d PEI:%d EAA:%d EMC:%d\n"
570 "Max_Legacy_SPD:%d BLINK:%d Bridge:%d\n"
571 "Page_Select:%d Port_Select%d\n",
572 b
.phy_id
, b
.r
, b
.cps
,
573 b
.rhb
, b
.ibr
, b
.gap_count
,
574 b
.extended
, b
.num_ports
,
575 b
.phy_speed
, b
.delay
,
576 b
.lctrl
, b
.c
, b
.jitter
, b
.pwr_class
,
577 b
.wdie
, b
.isbr
, b
.ctoi
, b
.cpsi
, b
.stoi
, b
.pei
, b
.eaa
, b
.emc
,
578 b
.legacy_spd
, b
.blink
, b
.bridge
,
579 b
.page_select
, b
.port_select
582 for (i
= 0; i
< b
.num_ports
; i
++) {
583 printf("\n=== page 0 port %d ===\n", i
);
584 read_phy_page(fd
, (u_int8_t
*)&p
, 0, i
);
586 "Astat:%d BStat:%d Ch:%d Con:%d RXOK:%d Dis:%d\n"
587 "Negotiated_speed:%d PIE:%d Fault:%d Stanby_fault:%d Disscrm:%d B_Only:%d\n"
588 "DC_connected:%d Max_port_speed:%d LPP:%d Cable_speed:%d\n"
589 "Connection_unreliable:%d Beta_mode:%d\n"
591 "Loop_disable:%d In_standby:%d Hard_disable:%d\n",
592 p
.astat
, p
.bstat
, p
.ch
, p
.con
, p
.rxok
, p
.dis
,
593 p
.negotiated_speed
, p
.pie
, p
.fault
, p
.stanby_fault
, p
.disscrm
, p
.b_only
,
594 p
.dc_connected
, p
.max_port_speed
, p
.lpp
, p
.cable_speed
,
595 p
.connection_unreliable
, p
.beta_mode
,
597 p
.loop_disable
, p
.in_standby
, p
.hard_disable
600 printf("\n=== page 1 ===\n");
601 read_phy_page(fd
, (u_int8_t
*)&v
, 1, 0);
605 "Product_ID:0x%06x\n",
607 (v
.vendor_id
[0] << 16) | (v
.vendor_id
[1] << 8) | v
.vendor_id
[2],
608 (v
.product_id
[0] << 16) | (v
.product_id
[1] << 8) | v
.product_id
[2]
613 open_dev(int *fd
, char *devbase
)
619 for (i
= 0; i
< 4; i
++) {
620 snprintf(name
, sizeof(name
), "%s.%d", devbase
, i
);
621 if ((*fd
= open(name
, O_RDWR
)) >= 0)
631 sysctl_set_int(const char *name
, int val
)
633 if (sysctlbyname(name
, NULL
, NULL
, &val
, sizeof(int)) < 0)
634 err(1, "sysctl %s failed.", name
);
638 detect_recv_fn(int fd
, char ich
)
641 struct fw_isochreq isoreq
;
642 struct fw_isobufreq bufreq
;
648 bufreq
.rx
.nchunk
= 8;
649 bufreq
.rx
.npacket
= 16;
650 bufreq
.rx
.psize
= 1024;
651 bufreq
.tx
.nchunk
= 0;
652 bufreq
.tx
.npacket
= 0;
655 if (ioctl(fd
, FW_SSTBUF
, &bufreq
) < 0)
656 err(1, "ioctl FW_SSTBUF");
658 isoreq
.ch
= ich
& 0x3f;
659 isoreq
.tag
= (ich
>> 6) & 3;
661 if (ioctl(fd
, FW_SRSTREAM
, &isoreq
) < 0)
662 err(1, "ioctl FW_SRSTREAM");
664 buf
= (char *)malloc(1024*16);
665 len
= read(fd
, buf
, 1024*16);
666 ptr
= (u_int32_t
*) buf
;
667 ciph
= (struct ciphdr
*)(ptr
+ 1);
671 fprintf(stderr
, "Detected DV format on input.\n");
675 fprintf(stderr
, "Detected MPEG TS format on input.\n");
679 errx(1, "Unsupported format for receiving: fmt=0x%x",
687 main(int argc
, char **argv
)
689 u_int32_t crom_buf
[1024/4];
690 char devbase
[1024] = "/dev/fw0";
691 int fd
, ch
, len
=1024;
695 fwmethod
*recvfn
= NULL
;
700 open_dev(&fd
, devbase
);
704 while ((ch
= getopt(argc
, argv
, "M:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1)
707 tmp
= strtol(optarg
, NULL
, 0);
708 if (tmp
< 0 || tmp
> (long)0xffffffff)
709 errx(EX_USAGE
, "invalid number: %s", optarg
);
710 open_dev(&fd
, devbase
);
711 set_pri_req(fd
, tmp
);
714 open_dev(&fd
, devbase
);
715 tmp
= str2node(fd
, optarg
);
716 get_crom(fd
, tmp
, crom_buf
, len
);
720 open_dev(&fd
, devbase
);
721 tmp
= str2node(fd
, optarg
);
722 get_crom(fd
, tmp
, crom_buf
, len
);
726 tmp
= strtol(optarg
, NULL
, 0);
727 open_dev(&fd
, devbase
);
728 send_phy_config(fd
, -1, tmp
);
731 load_crom(optarg
, crom_buf
);
735 if (eui64_hostton(optarg
, &target
) != 0 &&
736 eui64_aton(optarg
, &target
) != 0)
737 errx(EX_USAGE
, "invalid target: %s", optarg
);
738 eui
.hi
= ntohl(*(u_int32_t
*)&(target
.octet
[0]));
739 eui
.lo
= ntohl(*(u_int32_t
*)&(target
.octet
[4]));
740 sysctl_set_int("hw.fwmem.eui64_hi", eui
.hi
);
741 sysctl_set_int("hw.fwmem.eui64_lo", eui
.lo
);
744 open_dev(&fd
, devbase
);
745 tmp
= str2node(fd
, optarg
);
746 send_link_on(fd
, tmp
);
749 open_dev(&fd
, devbase
);
750 dump_phy_registers(fd
);
753 open_dev(&fd
, devbase
);
754 if(ioctl(fd
, FW_IBUSRST
, &tmp
) < 0)
758 open_dev(&fd
, devbase
);
759 tmp
= str2node(fd
, optarg
);
760 reset_start(fd
, tmp
);
763 open_dev(&fd
, devbase
);
764 show_topology_map(fd
);
767 tmp
= strtol(optarg
, NULL
, 0);
768 snprintf(devbase
, sizeof(devbase
), "/dev/fw%ld", tmp
);
773 if (argc
== optind
) {
774 open_dev(&fd
, devbase
);
789 errx(EX_USAGE
, "unrecognized method: %s",
794 open_dev(&fd
, devbase
);
795 if (recvfn
== NULL
) /* guess... */
796 recvfn
= detect_recv_fn(fd
, TAG
| CHANNEL
);
799 open_dev(&fd
, devbase
);
800 (*recvfn
)(fd
, optarg
, TAG
| CHANNEL
, -1);
803 open_dev(&fd
, devbase
);
804 dvsend(fd
, optarg
, TAG
| CHANNEL
, -1);