Lines Matching defs:gstate
325 static server_state_t gstate;
683 sltmp->next = gstate.leases.sleases;
684 gstate.leases.sleases = sltmp;
778 if (gstate.listensock > 0) close(gstate.listensock);
782 gstate.listensock = xsocket(PF_INET6, SOCK_DGRAM, 0);
783 setsockopt(gstate.listensock, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone));
784 setsockopt(gstate.listensock, IPPROTO_IPV6, IPV6_CHECKSUM, &constone, sizeof(constone));
786 if (setsockopt(gstate.listensock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &constone,
789 close(gstate.listensock);
793 setsockopt(gstate.listensock, SOL_SOCKET, SO_BINDTODEVICE, gconfig.interface, strlen(gconfig.interface)+1);
802 if (bind(gstate.listensock, (struct sockaddr *) &addr6, sizeof(addr6)) == -1) {
803 close(gstate.listensock);
811 if(setsockopt(gstate.listensock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) == -1) {
813 close(gstate.listensock);
827 if (gstate.listensock > 0) close(gstate.listensock);
830 gstate.listensock = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
831 setsockopt(gstate.listensock, SOL_SOCKET, SO_REUSEADDR, &constone, sizeof(constone));
832 if (setsockopt(gstate.listensock, SOL_SOCKET, SO_BROADCAST, &constone, sizeof(constone)) == -1) {
834 close(gstate.listensock);
839 setsockopt(gstate.listensock, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
846 if (bind(gstate.listensock, (struct sockaddr *) &addr, sizeof(addr))) {
847 close(gstate.listensock);
862 memcpy(&packet.dhcp6, &gstate.send.send_pkt6, sizeof(dhcp6_msg_t));
882 memcpy(&packet.iph.ip6_dst, &gstate.client_nip6, sizeof(uint32_t)*4);
885 packet.udph.dest = gstate.client_port; //CLIENT_PORT
913 memcpy(&packet.dhcp, &gstate.send.send_pkt, sizeof(dhcp_msg_t));
924 memcpy(dest_sll.sll_addr, (broadcast)?bmacaddr:gstate.rcvd.rcvd_pkt.chaddr , 6);
931 padding = 308 - 1 - dhcp_opt_size(gstate.send.send_pkt.options);
934 packet.iph.daddr = (broadcast || (gstate.rcvd.rcvd_pkt.ciaddr == 0))?
935 INADDR_BROADCAST : gstate.rcvd.rcvd_pkt.ciaddr;
937 packet.udph.dest = gstate.client_port; //CLIENT_PORT
962 memset(&gstate.rcvd.rcvd_pkt6, 0, sizeof(dhcp6_msg_t));
963 ret = recvfrom(gstate.listensock, &gstate.rcvd.rcvd_pkt6, sizeof(dhcp6_msg_t),
965 memcpy(gstate.client_nip6, &c_addr.sin6_addr, sizeof(uint32_t)*4);
966 memcpy(&gstate.client_port, &c_addr.sin6_port, sizeof(uint32_t));
971 if (gstate.rcvd.rcvd_pkt6.msgtype < 1) {
987 memset(&gstate.rcvd.rcvd_pkt, 0, sizeof(dhcp_msg_t));
988 ret = recvfrom(gstate.listensock, &gstate.rcvd.rcvd_pkt, sizeof(dhcp_msg_t),
990 memcpy(&gstate.client_port, &c_addr.sin_port, sizeof(uint32_t));
991 /*ret = read(gstate.listensock, &gstate.rcvd.rcvd_pkt, sizeof(dhcp_msg_t));*/
996 if (gstate.rcvd.rcvd_pkt.cookie != htonl(DHCP_MAGIC)) {
1000 if (gstate.rcvd.rcvd_pkt.op != 1) { //BOOTPREQUEST
1004 if (gstate.rcvd.rcvd_pkt.hlen != 6) {
1015 memset((void*)&gstategstate.send.send_pkt));
1016 gstate.send.send_pkt.op = 2; //BOOTPREPLY
1017 gstate.send.send_pkt.htype = 1;
1018 gstate.send.send_pkt.hlen = 6;
1019 gstate.send.send_pkt.xid = gstate.rcvd.rcvd_pkt.xid;
1020 gstate.send.send_pkt.cookie = htonl(DHCP_MAGIC);
1021 gstate.send.send_pkt.nsiaddr = gconfig.server_nip;
1022 memcpy(gstate.send.send_pkt.chaddr, gstate.rcvd.rcvd_pkt.chaddr, 16);
1023 gstate.send.send_pkt.options[0] = DHCP_OPT_END;
1024 return gstate.send.send_pkt.options;
1029 memset((void*)&gstate.send.send_pkt6, 0, sizeof(gstate.send.send_pkt6));
1030 gstate.send.send_pkt6.msgtype = opt;
1031 memcpy(gstate.send.send_pkt6.transaction_id, gstate.rcvd.rcvd_pkt6.transaction_id, 3);
1032 return gstate.send.send_pkt6.options;
1096 if ((overloaded == 1) | (overloaded == 3)) get_optval((uint8_t*)&gstate.rcvd.rcvd_pkt.file, opt, var);
1097 if ((overloaded == 2) | (overloaded == 3)) get_optval((uint8_t*)&gstate.rcvd.rcvd_pkt.sname, opt, var);
1133 for (optptr = gstate.rcvd.rcvd_pkt.options;
1199 struct arg_list *listdls = gstate.dleases;
1236 struct arg_list *listdls = gstate.dleases;
1311 for (listdls = gstate.dleases; listdls; listdls = listdls->next) {
1319 for (sls6 = gstate.leases.sleases6; sls6; sls6 = sls6->next)
1335 for (listdls = gstate.dleases; listdls; listdls = listdls->next) {
1343 for (sls = gstate.leases.sleases; sls; sls = sls->next)
1356 struct arg_list *listdls = gstate.dleases;
1377 listdls->next = gstate.dleases;
1379 gstate.dleases = listdls;
1387 struct arg_list *listdls = gstate.dleases;
1410 listdls->next = gstate.dleases;
1412 gstate.dleases = listdls;
1420 struct arg_list *listdls = gstate.dleases;
1436 static_lease *sls = gstate.leases.sleases;
1437 struct arg_list *listdls = gstate.dleases, *tmp = NULL;
1446 else gstate.dleases = listdls->next;
1483 static_lease6 *sls6 = gstate.leases.sleases6;
1484 struct arg_list *listdls6 = gstate.dleases, *tmp = NULL;
1490 else gstate.dleases = listdls6->next;
1670 fcntl(gstate.listensock, F_SETFD, FD_CLOEXEC);
1675 FD_SET(gstate.listensock, &rfds);
1683 int maxfd = (sigfd.rd > gstate.listensock)? sigfd.rd : gstate.listensock;
1727 if (FD_ISSET(gstate.listensock, &rfds)) { // Some Activity on RDFDs : is socket
1742 memcpy(&gstate.rqcode, &gstate.rcvd.rcvd_pkt6.msgtype, sizeof(uint8_t));
1743 memcpy(&transactionid, &gstate.rcvd.rcvd_pkt6.transaction_id,
1746 if (!gstate.rqcode || gstate.rqcode < DHCP6SOLICIT ||
1747 gstate.rqcode > DHCP6RELAYREPLY) {
1751 if (!gstate.rcvd.rcvd_pkt6.transaction_id ||
1752 memcmp(gstate.rcvd.rcvd_pkt6.transaction_id, transactionid, 3)) {
1758 switch (gstate.rqcode) {
1768 get_optval6((uint8_t*)&gstate.rcvd.rcvd_pkt6.options,
1772 if(get_optval6((uint8_t*)&gstate.rcvd.rcvd_pkt6.options,
1848 else if(get_optval6((uint8_t*)&gstate.rcvd.rcvd_pkt6.options,
1891 get_optval6((uint8_t*)&gstate.rcvd.rcvd_pkt6.options,
1900 if(get_optval6((uint8_t*)&gstate.rcvd.rcvd_pkt6.options,
1957 get_optval6((uint8_t*)&gstate.rcvd.rcvd_pkt6.options,
1976 dbg("Message Type : %u\n", gstate.rqcode);
1987 get_optval((uint8_t*)&gstate.rcvd.rcvd_pkt.options,
1988 DHCP_OPT_MESSAGE_TYPE, &gstate.rqcode);
1989 if (gstate.rqcode == 0 || gstate.rqcode < DHCPDISCOVER
1990 || gstate.rqcode > DHCPINFORM) {
1994 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2002 switch (gstate.rqcode) {
2006 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2008 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2011 get_reqparam(&gstate.rqopt);
2013 gstate.send.send_pkt.yiaddr = getip_from_pool(requested_nip,
2014 gstate.rcvd.rcvd_pkt.chaddr, &reqested_lease, hstname);
2015 if(!gstate.send.send_pkt.yiaddr){
2021 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2027 optptr = set_reqparam(optptr, gstate.rqopt);
2034 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2036 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2038 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2040 gstate.send.send_pkt.yiaddr = getip_from_pool(requested_nip,
2041 gstate.rcvd.rcvd_pkt.chaddr, &reqested_lease, hstname);
2043 if (!gstate.send.send_pkt.yiaddr) {
2059 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2062 get_optval((uint8_t*) &gstate.rcvd.rcvd_pkt.options,
2064 delip_from_lease(requested_nip, gstate.rcvd.rcvd_pkt.chaddr,
2065 (gstate.rqcode==DHCPRELEASE)?0:gconfig.decline_time);
2068 dbg("Message Type : %u\n", gstate.rqcode);