Lines Matching +full:magic +full:- +full:packet
30 #define R_IO_ERROR -1
55 int igmpfd = -1;
56 int nfd = -1;
57 int lfd = -1;
65 "Usage: %s [-d] [-p port] [-i address] -I <interface>\n",
106 while ((opt = getopt(argc, argv, "di:I:p:")) != -1)
140 case -1 :
167 if (lfd != -1) {
169 lfd = -1;
171 if (nfd != -1) {
173 nfd = -1;
175 if (igmpfd != -1) {
177 igmpfd = -1;
180 if (buildsocket(interface, &sin) == -1)
184 if (lfd == -1) {
191 tries = -1;
202 if (lfd != -1)
204 if (nfd != -1)
258 n1 = read(lfd, buff+inbuf, BUFFERLEN-inbuf); in do_io()
263 syslog(LOG_ERR, "read error (k-header): %m"); in do_io()
264 debug(1, "read error (k-header): %s\n", in do_io()
290 syslog(LOG_ERR, "read error (n-header): %m"); in do_io()
291 debug(1, "read error (n-header): %s\n", in do_io()
317 debug(2, "binding to %s:%s\n", nicname, inet_ntoa(sinp->sin_addr));
319 if (IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
324 if (igmpfd == -1) {
327 return -1;
332 req.ifr_name[sizeof(req.ifr_name) - 1] = '\0';
333 if (ioctl(igmpfd, SIOCGIFADDR, &req) == -1) {
337 igmpfd = -1;
338 return -1;
342 addr = reqip->sin_addr;
344 (char *)&addr, sizeof(addr)) == -1) {
350 igmpfd = -1;
351 return -1;
356 (char *)&opt, sizeof(opt)) == -1) {
361 igmpfd = -1;
362 return -1;
367 (char *)&opt, sizeof(opt)) == -1) {
373 igmpfd = -1;
374 return -1;
377 mreq.imr_multiaddr.s_addr = sinp->sin_addr.s_addr;
378 mreq.imr_interface.s_addr = reqip->sin_addr.s_addr;
381 (char *)&mreq, sizeof(mreq)) == -1) {
384 snprintf(buffer, sizeof(buffer), "%s,", inet_ntoa(sinp->sin_addr));
385 strcat(buffer, inet_ntoa(reqip->sin_addr));
392 igmpfd = -1;
393 return -1;
397 if (nfd == -1) {
399 if (igmpfd != -1) {
401 igmpfd = -1;
403 return -1;
407 req.ifr_name[sizeof(req.ifr_name) - 1] = '\0';
408 if (ioctl(nfd, SIOCGIFADDR, &req) == -1) {
412 igmpfd = -1;
413 return -1;
417 sizeof(req.ifr_addr)) == -1) {
421 if (igmpfd != -1) {
423 igmpfd = -1;
425 nfd = -1;
426 return -1;
429 if (connect(nfd, (struct sockaddr *)sinp, sizeof(*sinp)) == -1) {
433 if (igmpfd != -1) {
435 igmpfd = -1;
437 nfd = -1;
438 return -1;
440 syslog(LOG_INFO, "Sending data to %s", inet_ntoa(sinp->sin_addr));
441 debug(3, "Sending data to %s\n", inet_ntoa(sinp->sin_addr));
453 u_32_t magic; local
460 syslog(LOG_ERR, "packet length too short:%d", pklen);
461 debug(2, "packet length too short:%d\n", pklen);
466 len = ntohl(sh->sm_len);
467 magic = ntohl(sh->sm_magic);
469 if (magic != SYNHDRMAGIC) {
470 syslog(LOG_ERR, "invalid header magic %x", magic);
471 debug(2, "invalid header magic %x\n", magic);
476 syslog(LOG_ERR, "packet length too short:%d", pklen);
477 debug(2, "packet length too short:%d\n", pklen);
483 printcommand(sh->sm_cmd);
484 printtable(sh->sm_table);
498 n2 -= n3;
500 pklen -= n3;
515 u_32_t magic; local
530 len = ntohl(sh->sm_len);
531 magic = ntohl(sh->sm_magic);
533 if (magic != SYNHDRMAGIC) {
535 "read invalid header magic 0x%x, flushing",
536 magic);
537 debug(2, "read invalid header magic 0x%x, flushing\n",
538 magic);
546 printcommand(sh->sm_cmd);
547 printtable(sh->sm_table);
564 bytes -= sendlen;
643 if (sh->sm_cmd == SMC_CREATE) {
646 } else if (sh->sm_cmd == SMC_UPDATE) {
648 if (sh->sm_p == IPPROTO_TCP) {
650 su->sup_tcp.stu_age,
651 su->sup_tcp.stu_state[0],
652 su->sup_tcp.stu_state[1]);
665 printf("v:%d p:%d num:%d len:%d magic:%x", sh->sm_v, sh->sm_p,
666 ntohl(sh->sm_num), ntohl(sh->sm_len), ntohl(sh->sm_magic));