Lines Matching refs:TT

181   TT.length += 4;
186 uint8_t *tmp = &mesg.options[TT.length];
195 get_mac(mac, TT.interface_name);
203 TT.length += sizeof(DUID);
209 uint8_t *tmp = &mesg.options[TT.length];
214 TT.length += 4;
219 uint8_t *tmp = &mesg.options[TT.length];
223 TT.length += 2;
229 uint8_t *tmp = &mesg.options[TT.length];
236 TT.length += sizeof(IA_NA);
245 if (TT.sock > 0) xclose(TT.sock);
246 TT.sock = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6));
251 sockll.sll_ifindex = if_nametoindex(TT.interface_name);
252 xbind(TT.sock, (struct sockaddr *) &sockll, sizeof(sockll));
253 if (setsockopt(TT.sock, SOL_PACKET, PACKET_HOST,&constone, sizeof(int)) < 0) {
263 TT.transction_id[i] = r%0xff;
270 TT.tv.tv_sec = seconds;
271 TT.tv.tv_usec = 100000;
285 memcpy(mesg.transaction_id, TT.transction_id, 3);
288 TT.length = 0;
293 sendlength = sizeof(dhcp6_msg_t) - 524 + TT.length;
295 sendlength = TT.request_length;
297 sendlength = sendto(TT.sock1, &mesg, sendlength , 0,(struct sockaddr *)&addr6,
339 TT.status - ((char*)&mymsg->dhcp6.options[0] - (char*)mymsg) )) {
344 TT.status - ((char*)&mymsg->dhcp6.options[0] - (char*)mymsg) )) {
373 if (TT.state == DHCP6SOLICIT) {
374 if (TT.req_ip) {
377 if(!getaddrinfo(TT.req_ip, NULL, NULL,&res)) {
378 dbg("Requesting IP: %s\n", TT.req_ip);
379 memcpy (&TT.input_socket6, res->ai_addr, res->ai_addrlen);
380 memcpy(t+4, TT.input_socket6.sin6_addr.s6_addr, 16);
381 } else xprintf("Invalid IP: %s\n",TT.req_ip);
421 int ret = setenv("interface", TT.interface_name, 1);
436 char *script = (toys.optflags & FLAG_s) ? TT.script
473 xclose(TT.sock);
474 xclose(TT.sock1);
480 if (toys.optflags & FLAG_p) write_pid(TT.pidfile);
493 if (TT.state == DHCP6RELEASE || TT.state == DHCP6REQUEST ) {
494 TT.state = DHCP6SOLICIT;
500 TT.state = DHCP6RENEW;
501 TT.retries = 0;
506 if (TT.state == DHCP6RELEASE) return;
507 if (TT.state != DHCP6CONFIRM ) return;
510 TT.state = DHCP6RELEASE;
511 TT.retries = 0;
517 if ((toys.optflags & FLAG_R) && TT.state == DHCP6CONFIRM)
544 TT.state = DHCP6SOLICIT;
547 if (!TT.interface_name) TT.interface_name = "eth0";
548 if (toys.optflags & FLAG_p) write_pid(TT.pidfile);
549 if (!TT.retry) TT.retry = 3;
550 if (!TT.timeout) TT.timeout = 3;
551 if (!TT.errortimeout) TT.errortimeout = 20;
557 dbg("Interface: %s\n", TT.interface_name);
558 dbg("pid file: %s\n", TT.pidfile);
559 dbg("Retry count: %d\n", TT.retry);
560 dbg("Timeout : %d\n", TT.timeout);
561 dbg("Error timeout: %d\n", TT.errortimeout);
566 TT.sock1 = xsocket(PF_INET6, SOCK_DGRAM, 0);
570 sinaddr6.sin6_scope_id = if_nametoindex(TT.interface_name);
573 xsetsockopt(TT.sock1, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone));
575 xbind(TT.sock1, (struct sockaddr *)&sinaddr6, sizeof(sinaddr6));
580 int maxfd = TT.sock;
582 if (TT.sock >= 0) FD_SET(TT.sock, &rfds);
583 TT.retval = 0;
584 if ((TT.retval = select(maxfd + 1, &rfds, NULL, NULL, &TT.tv)) < 0) {
588 if (!TT.retval) {
589 if (TT.state == DHCP6SOLICIT || TT.state == DHCP6CONFIRM) {
593 TT.state = DHCP6SOLICIT;
594 TT.retries++;
595 if(TT.retries > TT.retry) set_timeout(TT.errortimeout);
596 else if (TT.retries == TT.retry) {
599 set_timeout(TT.errortimeout);
600 } else set_timeout(TT.timeout);
602 } else if (TT.state == DHCP6REQUEST || TT.state == DHCP6RENEW ||
603 TT.state == DHCP6RELEASE) {
604 dbg("State is %d , sending packet\n", TT.state);
605 send_msg(TT.state);
606 TT.retries++;
607 if (TT.retries > TT.retry) set_timeout(TT.errortimeout);
608 else if (TT.retries == TT.retry) {
610 set_timeout(TT.errortimeout);
611 } else set_timeout(TT.timeout);
614 } else if (FD_ISSET(TT.sock, &rfds)) {
615 if ((TT.status = read(TT.sock, toybuf, sizeof(toybuf))) <= 0) continue;
618 !memcmp(mymsg->dhcp6.transaction_id, TT.transction_id, 3)) {
619 if (TT.state == DHCP6SOLICIT) {
623 TT.state = DHCP6SOLICIT;
627 TT.retries = 0;
629 TT.request_length = TT.status - ((char*)&mymsg->dhcp6 - (char*)mymsg);
630 memcpy((uint8_t*)&mesg, &mymsg->dhcp6, TT.request_length);
631 parse_ia_na(mesg.options, TT.request_length);
635 TT.state = DHCP6REQUEST;
640 } else if (TT.state == DHCP6REQUEST || TT.state == DHCP6RENEW ) {
643 dbg("Invalid id received, %d.\n", TT.state);
644 TT.state = DHCP6REQUEST;
648 TT.request_length = TT.status - ((char*)&mymsg->dhcp6 - (char*)mymsg);
649 memcpy((uint8_t*)&mesg, &mymsg->dhcp6, TT.request_length);
650 parse_ia_na(mymsg->dhcp6.options, TT.request_length);
654 TT.retries = 0;
655 run_script(&dhcp_data, (TT.state == DHCP6REQUEST) ?
661 TT.state = DHCP6CONFIRM;
664 if (TT.state == DHCP6REQUEST || !(toys.optflags & FLAG_f)) {
668 if (toys.optflags & FLAG_p) write_pid(TT.pidfile);
676 } else if (TT.state == DHCP6RELEASE) {
684 xclose(TT.sock1);
685 xclose(TT.sock);