Mercurial > hg > freeDiameter
comparison freeDiameter/p_sr.c @ 165:4679ff581d6a
Fix invalid restore of the hop-by-hop id on forwarded answers
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 27 Jan 2010 10:56:54 +0900 |
parents | 9dcb1bd11a07 |
children | 5df55136361b |
comparison
equal
deleted
inserted
replaced
164:6f6fd233b923 | 165:4679ff581d6a |
---|---|
41 | 41 |
42 /* Structure to store a sent request */ | 42 /* Structure to store a sent request */ |
43 struct sentreq { | 43 struct sentreq { |
44 struct fd_list chain; /* the "o" field points directly to the hop-by-hop of the request (uint32_t *) */ | 44 struct fd_list chain; /* the "o" field points directly to the hop-by-hop of the request (uint32_t *) */ |
45 struct msg *req; /* A request that was sent and not yet answered. */ | 45 struct msg *req; /* A request that was sent and not yet answered. */ |
46 uint32_t prevhbh;/* The value to set in the hbh header when the message is retrieved */ | |
46 }; | 47 }; |
47 | 48 |
48 /* Find an element in the list, or the following one */ | 49 /* Find an element in the list, or the following one */ |
49 static struct fd_list * find_or_next(struct fd_list * srlist, uint32_t hbh, int * match) | 50 static struct fd_list * find_or_next(struct fd_list * srlist, uint32_t hbh, int * match) |
50 { | 51 { |
74 fd_msg_dump_one(SR_DEBUG_LVL + 1, sr->req); | 75 fd_msg_dump_one(SR_DEBUG_LVL + 1, sr->req); |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
78 /* Store a new sent request */ | 79 /* Store a new sent request */ |
79 int fd_p_sr_store(struct sr_list * srlist, struct msg **req, uint32_t *hbhloc) | 80 int fd_p_sr_store(struct sr_list * srlist, struct msg **req, uint32_t *hbhloc, uint32_t hbh_restore) |
80 { | 81 { |
81 struct sentreq * sr; | 82 struct sentreq * sr; |
82 struct fd_list * next; | 83 struct fd_list * next; |
83 int match; | 84 int match; |
84 | 85 |
85 TRACE_ENTRY("%p %p %p", srlist, req, hbhloc); | 86 TRACE_ENTRY("%p %p %p %x", srlist, req, hbhloc, hbh_restore); |
86 CHECK_PARAMS(srlist && req && *req && hbhloc); | 87 CHECK_PARAMS(srlist && req && *req && hbhloc); |
87 | 88 |
88 CHECK_MALLOC( sr = malloc(sizeof(struct sentreq)) ); | 89 CHECK_MALLOC( sr = malloc(sizeof(struct sentreq)) ); |
89 memset(sr, 0, sizeof(struct sentreq)); | 90 memset(sr, 0, sizeof(struct sentreq)); |
90 fd_list_init(&sr->chain, hbhloc); | 91 fd_list_init(&sr->chain, hbhloc); |
91 sr->req = *req; | 92 sr->req = *req; |
93 sr->prevhbh = hbh_restore; | |
92 | 94 |
93 /* Search the place in the list */ | 95 /* Search the place in the list */ |
94 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) ); | 96 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) ); |
95 next = find_or_next(&srlist->srs, *hbhloc, &match); | 97 next = find_or_next(&srlist->srs, *hbhloc, &match); |
96 if (match) { | 98 if (match) { |
120 /* Search the request in the list */ | 122 /* Search the request in the list */ |
121 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) ); | 123 CHECK_POSIX( pthread_mutex_lock(&srlist->mtx) ); |
122 srl_dump("Fetching a request, ", &srlist->srs); | 124 srl_dump("Fetching a request, ", &srlist->srs); |
123 sr = (struct sentreq *)find_or_next(&srlist->srs, hbh, &match); | 125 sr = (struct sentreq *)find_or_next(&srlist->srs, hbh, &match); |
124 if (!match) { | 126 if (!match) { |
125 TRACE_DEBUG(INFO, "There is no saved request with this hop-by-hop id"); | 127 TRACE_DEBUG(INFO, "There is no saved request with this hop-by-hop id (%x)", hbh); |
126 *req = NULL; | 128 *req = NULL; |
127 } else { | 129 } else { |
130 /* Restore hop-by-hop id */ | |
131 *((uint32_t *)sr->chain.o) = sr->prevhbh; | |
128 /* Unlink */ | 132 /* Unlink */ |
129 fd_list_unlink(&sr->chain); | 133 fd_list_unlink(&sr->chain); |
130 *req = sr->req; | 134 *req = sr->req; |
131 free(sr); | 135 free(sr); |
132 } | 136 } |