Changeset bbb7ffe in mainline
- Timestamp:
- 2022-06-24T09:40:05Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b7155d7
- Parents:
- 52214a2
- git-author:
- Jiri Svoboda <jiri@…> (2022-07-23 19:39:46)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-06-24 09:40:05)
- Location:
- uspace/srv/net/dhcp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dhcp/dhcp.c
r52214a2 rbbb7ffe 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 47 47 #include <io/log.h> 48 48 #include <loc.h> 49 #include <rndgen.h> 49 50 #include <stdio.h> 50 51 #include <stdlib.h> … … 95 96 /** DNS server */ 96 97 inet_addr_t dns_server; 98 /** Transaction ID */ 99 uint32_t xid; 97 100 } dhcp_offer_t; 98 101 … … 114 117 /** Last received offer */ 115 118 dhcp_offer_t offer; 119 /** Random number generator */ 120 rndgen_t *rndgen; 116 121 } dhcp_link_t; 117 122 … … 154 159 dhcp_hdr_t *hdr = (dhcp_hdr_t *)msgbuf; 155 160 uint8_t *opt = msgbuf + sizeof(dhcp_hdr_t); 161 uint32_t xid; 162 errno_t rc; 163 164 rc = rndgen_uint32(dlink->rndgen, &xid); 165 if (rc != EOK) 166 return rc; 156 167 157 168 memset(msgbuf, 0, MAX_MSG_SIZE); … … 159 170 hdr->htype = 1; /* AHRD_ETHERNET */ 160 171 hdr->hlen = ETH_ADDR_SIZE; 161 hdr->xid = host2uint32_t_be( 42);162 hdr->flags = flag_broadcast;172 hdr->xid = host2uint32_t_be(xid); 173 hdr->flags = host2uint16_t_be(flag_broadcast); 163 174 164 175 eth_addr_encode(&dlink->link_info.mac_addr, hdr->chaddr); … … 168 179 opt[1] = 1; 169 180 opt[2] = msg_dhcpdiscover; 181 170 182 opt[3] = opt_end; 171 183 … … 183 195 hdr->htype = 1; /* AHRD_ETHERNET */ 184 196 hdr->hlen = 6; 185 hdr->xid = host2uint32_t_be( 42);186 hdr->flags = flag_broadcast;197 hdr->xid = host2uint32_t_be(offer->xid); 198 hdr->flags = host2uint16_t_be(flag_broadcast); 187 199 eth_addr_encode(&dlink->link_info.mac_addr, hdr->chaddr); 188 200 hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic); … … 257 269 258 270 inet_naddr_set(yiaddr.addr, 0, &offer->oaddr); 271 offer->xid = uint32_t_be2host(hdr->xid); 259 272 260 273 msgb = (uint8_t *)msg; … … 456 469 return ENOMEM; 457 470 471 rc = rndgen_create(&dlink->rndgen); 472 if (rc != EOK) 473 goto error; 474 458 475 dlink->link_id = link_id; 459 476 dlink->timeout = fibril_timer_create(NULL); … … 493 510 return EOK; 494 511 error: 512 if (dlink != NULL && dlink->rndgen != NULL) 513 rndgen_destroy(dlink->rndgen); 495 514 if (dlink != NULL && dlink->timeout != NULL) 496 515 fibril_timer_destroy(dlink->timeout); -
uspace/srv/net/dhcp/dhcp_std.h
r52214a2 rbbb7ffe 1 1 /* 2 * Copyright (c) 20 13Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 87 87 /** Values for dhcp_hdr_t.flags */ 88 88 enum dhcp_flags { 89 flag_broadcast = 0x80 89 flag_broadcast = 0x8000 90 90 }; 91 91
Note:
See TracChangeset
for help on using the changeset viewer.