Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 40859
Collapse All | Expand All

(-)l2tpd-0.69/aaa.c (-23 / +23 lines)
Lines 142-148 Link Here
142
    f = fopen (gconfig.authfile, "r");
142
    f = fopen (gconfig.authfile, "r");
143
    if (!f)
143
    if (!f)
144
    {
144
    {
145
        log (LOG_WARN, "%s : Unable to open '%s' for authentication\n",
145
        _log (LOG_WARN, "%s : Unable to open '%s' for authentication\n",
146
             __FUNCTION__, gconfig.authfile);
146
             __FUNCTION__, gconfig.authfile);
147
        return 0;
147
        return 0;
148
    }
148
    }
Lines 166-172 Link Here
166
        /* us */
166
        /* us */
167
        if (!*u)
167
        if (!*u)
168
        {
168
        {
169
            log (LOG_WARN,
169
            _log (LOG_WARN,
170
                 "%s: Invalid authentication info (no us), line %d\n",
170
                 "%s: Invalid authentication info (no us), line %d\n",
171
                 __FUNCTION__, num);
171
                 __FUNCTION__, num);
172
            continue;
172
            continue;
Lines 180-186 Link Here
180
        /* them */
180
        /* them */
181
        if (!*t)
181
        if (!*t)
182
        {
182
        {
183
            log (LOG_WARN,
183
            _log (LOG_WARN,
184
                 "%s: Invalid authentication info (nothem), line %d\n",
184
                 "%s: Invalid authentication info (nothem), line %d\n",
185
                 __FUNCTION__, num);
185
                 __FUNCTION__, num);
186
            continue;
186
            continue;
Lines 193-199 Link Here
193
            s++;
193
            s++;
194
        if (!*s)
194
        if (!*s)
195
        {
195
        {
196
            log (LOG_WARN,
196
            _log (LOG_WARN,
197
                 "%s: Invalid authentication info (no secret), line %d\n",
197
                 "%s: Invalid authentication info (no secret), line %d\n",
198
                 __FUNCTION__, num);
198
                 __FUNCTION__, num);
199
            continue;
199
            continue;
Lines 202-208 Link Here
202
            (!strcasecmp (t, them) || !strcasecmp (t, "*")))
202
            (!strcasecmp (t, them) || !strcasecmp (t, "*")))
203
        {
203
        {
204
#ifdef DEBUG_AUTH
204
#ifdef DEBUG_AUTH
205
            log (LOG_DEBUG,
205
            _log (LOG_DEBUG,
206
                 "%s: we are '%s', they are '%s', secret is '%s'\n",
206
                 "%s: we are '%s', they are '%s', secret is '%s'\n",
207
                 __FUNCTION__, u, t, s);
207
                 __FUNCTION__, u, t, s);
208
#endif
208
#endif
Lines 219-230 Link Here
219
    char *them;
219
    char *them;
220
    if (!t->lns && !t->lac)
220
    if (!t->lns && !t->lac)
221
    {
221
    {
222
        log (LOG_DEBUG, "%s: No LNS or LAC to handle challenge!\n",
222
        _log (LOG_DEBUG, "%s: No LNS or LAC to handle challenge!\n",
223
             __FUNCTION__);
223
             __FUNCTION__);
224
        return -1;
224
        return -1;
225
    }
225
    }
226
#ifdef DEBUG_AUTH
226
#ifdef DEBUG_AUTH
227
    log (LOG_DEBUG, "%s: making response for tunnel: %d\n", __FUNCTION__,
227
    _log (LOG_DEBUG, "%s: making response for tunnel: %d\n", __FUNCTION__,
228
         t->ourtid);
228
         t->ourtid);
229
#endif
229
#endif
230
    if (t->lns)
230
    if (t->lns)
Lines 251-269 Link Here
251
    }
251
    }
252
    if (!get_secret (us, them, chal->secret, sizeof (chal->secret)))
252
    if (!get_secret (us, them, chal->secret, sizeof (chal->secret)))
253
    {
253
    {
254
        log (LOG_DEBUG, "%s: no secret found for us='%s' and them='%s'\n",
254
        _log (LOG_DEBUG, "%s: no secret found for us='%s' and them='%s'\n",
255
             __FUNCTION__, us, them);
255
             __FUNCTION__, us, them);
256
        return -1;
256
        return -1;
257
    }
257
    }
258
258
259
#if DEBUG_AUTH
259
#if DEBUG_AUTH
260
    log (LOG_DEBUG, "*%s: Here comes the chal->ss:\n", __FUNCTION__);
260
    _log (LOG_DEBUG, "*%s: Here comes the chal->ss:\n", __FUNCTION__);
261
    bufferDump (&chal->ss, 1);
261
    bufferDump (&chal->ss, 1);
262
262
263
    log (LOG_DEBUG, "%s: Here comes the secret\n", __FUNCTION__);
263
    _log (LOG_DEBUG, "%s: Here comes the secret\n", __FUNCTION__);
264
    bufferDump (chal->secret, strlen (chal->secret));
264
    bufferDump (chal->secret, strlen (chal->secret));
265
265
266
    log (LOG_DEBUG, "%s: Here comes the challenge\n", __FUNCTION__);
266
    _log (LOG_DEBUG, "%s: Here comes the challenge\n", __FUNCTION__);
267
    bufferDump (chal->challenge, strlen (chal->challenge));
267
    bufferDump (chal->challenge, strlen (chal->challenge));
268
#endif
268
#endif
269
269
Lines 274-280 Link Here
274
    MD5Update (&chal->md5, chal->challenge, strlen(chal->challenge));
274
    MD5Update (&chal->md5, chal->challenge, strlen(chal->challenge));
275
    MD5Final (chal->response, &chal->md5);
275
    MD5Final (chal->response, &chal->md5);
276
#ifdef DEBUG_AUTH
276
#ifdef DEBUG_AUTH
277
    log (LOG_DEBUG, "response is %X%X%X%X to '%s' and %X%X%X%X, %d\n",
277
    _log (LOG_DEBUG, "response is %X%X%X%X to '%s' and %X%X%X%X, %d\n",
278
         *((int *) &chal->response[0]),
278
         *((int *) &chal->response[0]),
279
         *((int *) &chal->response[4]),
279
         *((int *) &chal->response[4]),
280
         *((int *) &chal->response[8]),
280
         *((int *) &chal->response[8]),
Lines 317-323 Link Here
317
                (ntohl (t->peer.sin_addr.s_addr) <= ntohl (ipr->end)))
317
                (ntohl (t->peer.sin_addr.s_addr) <= ntohl (ipr->end)))
318
            {
318
            {
319
#ifdef DEBUG_AAA
319
#ifdef DEBUG_AAA
320
                log (LOG_DEBUG,
320
                _log (LOG_DEBUG,
321
                     "get_lns: Rule %s to %s, sense %s matched %s\n",
321
                     "get_lns: Rule %s to %s, sense %s matched %s\n",
322
                     IPADDY (ipr->start), IPADDY (ipr->end),
322
                     IPADDY (ipr->start), IPADDY (ipr->end),
323
                     (ipr->sense ? "allow" : "deny"), IPADDY (t->addr));
323
                     (ipr->sense ? "allow" : "deny"), IPADDY (t->addr));
Lines 345-358 Link Here
345
void print_md5 (void *md5)
345
void print_md5 (void *md5)
346
{
346
{
347
    int *i = (int *) md5;
347
    int *i = (int *) md5;
348
    log (LOG_DEBUG, "%X%X%X%X\n", i[0], i[1], i[2], i[3], i[4]);
348
    _log (LOG_DEBUG, "%X%X%X%X\n", i[0], i[1], i[2], i[3], i[4]);
349
}
349
}
350
350
351
inline void print_challenge (struct challenge *chal)
351
inline void print_challenge (struct challenge *chal)
352
{
352
{
353
    log (LOG_DEBUG, "vector: ");
353
    _log (LOG_DEBUG, "vector: ");
354
    print_md5 (chal->vector);
354
    print_md5 (chal->vector);
355
    log (LOG_DEBUG, "secret: %s\n", chal->secret);
355
    _log (LOG_DEBUG, "secret: %s\n", chal->secret);
356
}
356
}
357
#endif
357
#endif
358
void encrypt_avp (struct buffer *buf, _u16 len, struct tunnel *t)
358
void encrypt_avp (struct buffer *buf, _u16 len, struct tunnel *t)
Lines 401-409 Link Here
401
    while (ptr < end)
401
    while (ptr < end)
402
    {
402
    {
403
#if DEBUG_HIDDEN
403
#if DEBUG_HIDDEN
404
        log (LOG_DEBUG, "%s: The digest to be XOR'ed\n", __FUNCTION__);
404
        _log (LOG_DEBUG, "%s: The digest to be XOR'ed\n", __FUNCTION__);
405
        bufferDump (digest, MD_SIG_SIZE);
405
        bufferDump (digest, MD_SIG_SIZE);
406
        log (LOG_DEBUG, "%s: The plaintext to be XOR'ed\n", __FUNCTION__);
406
        _log (LOG_DEBUG, "%s: The plaintext to be XOR'ed\n", __FUNCTION__);
407
        bufferDump (ptr, MD_SIG_SIZE);
407
        bufferDump (ptr, MD_SIG_SIZE);
408
#endif
408
#endif
409
        for (cnt = 0; cnt < MD_SIG_SIZE; cnt++, ptr++)
409
        for (cnt = 0; cnt < MD_SIG_SIZE; cnt++, ptr++)
Lines 411-417 Link Here
411
            *ptr = *ptr ^ digest[cnt];
411
            *ptr = *ptr ^ digest[cnt];
412
        }
412
        }
413
#if DEBUG_HIDDEN
413
#if DEBUG_HIDDEN
414
        log (LOG_DEBUG, "%s: The result of XOR\n", __FUNCTION__);
414
        _log (LOG_DEBUG, "%s: The result of XOR\n", __FUNCTION__);
415
        bufferDump (previous_segment, MD_SIG_SIZE);
415
        bufferDump (previous_segment, MD_SIG_SIZE);
416
#endif
416
#endif
417
        if (ptr < end)
417
        if (ptr < end)
Lines 445-451 Link Here
445
    end = buf + olen;
445
    end = buf + olen;
446
    if (!t->chal_us.vector)
446
    if (!t->chal_us.vector)
447
    {
447
    {
448
        log (LOG_DEBUG,
448
        _log (LOG_DEBUG,
449
             "decrypt_avp: Hidden bit set, but no random vector specified!\n");
449
             "decrypt_avp: Hidden bit set, but no random vector specified!\n");
450
        return -EINVAL;
450
        return -EINVAL;
451
    }
451
    }
Lines 460-468 Link Here
460
    MD5Update (&t->chal_us.md5, t->chal_us.vector, t->chal_us.vector_len);
460
    MD5Update (&t->chal_us.md5, t->chal_us.vector, t->chal_us.vector_len);
461
    MD5Final (digest, &t->chal_us.md5);
461
    MD5Final (digest, &t->chal_us.md5);
462
#ifdef DEBUG_HIDDEN
462
#ifdef DEBUG_HIDDEN
463
    log (LOG_DEBUG, "attribute is %d and challenge is: ", attr);
463
    _log (LOG_DEBUG, "attribute is %d and challenge is: ", attr);
464
    print_challenge (&t->chal_us);
464
    print_challenge (&t->chal_us);
465
    log (LOG_DEBUG, "md5 is: ");
465
    _log (LOG_DEBUG, "md5 is: ");
466
    print_md5 (digest);
466
    print_md5 (digest);
467
#endif
467
#endif
468
    while (ptr < end)
468
    while (ptr < end)
Lines 494-500 Link Here
494
    len = ntohs (new_hdr->attr) + sizeof (struct avp_hdr);
494
    len = ntohs (new_hdr->attr) + sizeof (struct avp_hdr);
495
    if (len > olen - 2)
495
    if (len > olen - 2)
496
    {
496
    {
497
        log (LOG_DEBUG,
497
        _log (LOG_DEBUG,
498
             "decrypt_avp: Decrypted length is too long (%d > %d)\n", len,
498
             "decrypt_avp: Decrypted length is too long (%d > %d)\n", len,
499
             olen - 2);
499
             olen - 2);
500
        return -EINVAL;
500
        return -EINVAL;
(-)l2tpd-0.69/avp.c (-118 / +118 lines)
Lines 142-148 Link Here
142
    if (datalen != 8)
142
    if (datalen != 8)
143
    {
143
    {
144
        if (DEBUG)
144
        if (DEBUG)
145
            log (LOG_DEBUG, "%s: wrong size (%d != 8)\n", __FUNCTION__,
145
            _log (LOG_DEBUG, "%s: wrong size (%d != 8)\n", __FUNCTION__,
146
                 datalen);
146
                 datalen);
147
        wrong_length (c, "Message Type", 8, datalen, 0);
147
        wrong_length (c, "Message Type", 8, datalen, 0);
148
        return -EINVAL;
148
        return -EINVAL;
Lines 150-162 Link Here
150
    if ((c->msgtype > MAX_MSG) || (!msgtypes[c->msgtype]))
150
    if ((c->msgtype > MAX_MSG) || (!msgtypes[c->msgtype]))
151
    {
151
    {
152
        if (DEBUG)
152
        if (DEBUG)
153
            log (LOG_DEBUG, "%s: unknown message type %d\n", __FUNCTION__,
153
            _log (LOG_DEBUG, "%s: unknown message type %d\n", __FUNCTION__,
154
                 c->msgtype);
154
                 c->msgtype);
155
        return -EINVAL;
155
        return -EINVAL;
156
    }
156
    }
157
    if (debug_avp)
157
    if (debug_avp)
158
        if (DEBUG)
158
        if (DEBUG)
159
            log (LOG_DEBUG, "%s: message type %d (%s)\n", __FUNCTION__,
159
            _log (LOG_DEBUG, "%s: message type %d (%s)\n", __FUNCTION__,
160
                 c->msgtype, msgtypes[c->msgtype]);
160
                 c->msgtype, msgtypes[c->msgtype]);
161
#ifdef SANITY
161
#ifdef SANITY
162
    if (t->sanity)
162
    if (t->sanity)
Lines 168-174 Link Here
168
        if ((c != t->self) && (c->msgtype < Hello))
168
        if ((c != t->self) && (c->msgtype < Hello))
169
        {
169
        {
170
            if (DEBUG)
170
            if (DEBUG)
171
                log (LOG_DEBUG,
171
                _log (LOG_DEBUG,
172
                     "%s: attempting to negotiate tunnel inside a call!\n",
172
                     "%s: attempting to negotiate tunnel inside a call!\n",
173
                     __FUNCTION__);
173
                     __FUNCTION__);
174
            return -EINVAL;
174
            return -EINVAL;
Lines 185-191 Link Here
185
                 */
185
                 */
186
186
187
                if (DEBUG)
187
                if (DEBUG)
188
                    log (LOG_DEBUG,
188
                    _log (LOG_DEBUG,
189
                         "%s: attempting to negotiate SCCRQ with state != 0\n",
189
                         "%s: attempting to negotiate SCCRQ with state != 0\n",
190
                         __FUNCTION__);
190
                         __FUNCTION__);
191
                return -EINVAL;
191
                return -EINVAL;
Lines 195-201 Link Here
195
            if (t->state != SCCRQ)
195
            if (t->state != SCCRQ)
196
            {
196
            {
197
                if (DEBUG)
197
                if (DEBUG)
198
                    log (LOG_DEBUG,
198
                    _log (LOG_DEBUG,
199
                         "%s: attempting to negotiate SCCRP with state != SCCRQ!\n",
199
                         "%s: attempting to negotiate SCCRP with state != SCCRQ!\n",
200
                         __FUNCTION__);
200
                         __FUNCTION__);
201
                return -EINVAL;
201
                return -EINVAL;
Lines 205-211 Link Here
205
            if (t->state != SCCRP)
205
            if (t->state != SCCRP)
206
            {
206
            {
207
                if (DEBUG)
207
                if (DEBUG)
208
                    log (LOG_DEBUG,
208
                    _log (LOG_DEBUG,
209
                         "%s: attempting to negotiate SCCCN with state != SCCRP!\n",
209
                         "%s: attempting to negotiate SCCCN with state != SCCRP!\n",
210
                         __FUNCTION__);
210
                         __FUNCTION__);
211
                return -EINVAL;
211
                return -EINVAL;
Lines 215-221 Link Here
215
            if (t->state != SCCCN)
215
            if (t->state != SCCCN)
216
            {
216
            {
217
                if (DEBUG)
217
                if (DEBUG)
218
                    log (LOG_DEBUG,
218
                    _log (LOG_DEBUG,
219
                         "%s: attempting to negotiate ICRQ when state != SCCCN\n",
219
                         "%s: attempting to negotiate ICRQ when state != SCCCN\n",
220
                         __FUNCTION__);
220
                         __FUNCTION__);
221
                return -EINVAL;
221
                return -EINVAL;
Lines 223-229 Link Here
223
            if (c != t->self)
223
            if (c != t->self)
224
            {
224
            {
225
                if (DEBUG)
225
                if (DEBUG)
226
                    log (LOG_DEBUG,
226
                    _log (LOG_DEBUG,
227
                         "%s: attempting to negotiate ICRQ on a call!\n",
227
                         "%s: attempting to negotiate ICRQ on a call!\n",
228
                         __FUNCTION__);
228
                         __FUNCTION__);
229
                return -EINVAL;
229
                return -EINVAL;
Lines 233-239 Link Here
233
            if (t->state != SCCCN)
233
            if (t->state != SCCCN)
234
            {
234
            {
235
                if (DEBUG)
235
                if (DEBUG)
236
                    log (LOG_DEBUG,
236
                    _log (LOG_DEBUG,
237
                         "%s: attempting to negotiate ICRP on tunnel!=SCCCN\n",
237
                         "%s: attempting to negotiate ICRP on tunnel!=SCCCN\n",
238
                         __FUNCTION__);
238
                         __FUNCTION__);
239
                return -EINVAL;
239
                return -EINVAL;
Lines 241-247 Link Here
241
            if (c->state != ICRQ)
241
            if (c->state != ICRQ)
242
            {
242
            {
243
                if (DEBUG)
243
                if (DEBUG)
244
                    log (LOG_DEBUG,
244
                    _log (LOG_DEBUG,
245
                         "%s: attempting to negotiate ICRP when state != ICRQ\n",
245
                         "%s: attempting to negotiate ICRP when state != ICRQ\n",
246
                         __FUNCTION__);
246
                         __FUNCTION__);
247
                return -EINVAL;
247
                return -EINVAL;
Lines 251-257 Link Here
251
            if (c->state != ICRP)
251
            if (c->state != ICRP)
252
            {
252
            {
253
                if (DEBUG)
253
                if (DEBUG)
254
                    log (LOG_DEBUG,
254
                    _log (LOG_DEBUG,
255
                         "%s: attempting to negotiate ICCN when state != ICRP\n",
255
                         "%s: attempting to negotiate ICCN when state != ICRP\n",
256
                         __FUNCTION__);
256
                         __FUNCTION__);
257
                return -EINVAL;
257
                return -EINVAL;
Lines 261-267 Link Here
261
            if (c->state != ICCN)
261
            if (c->state != ICCN)
262
            {
262
            {
263
                if (DEBUG)
263
                if (DEBUG)
264
                    log (LOG_DEBUG,
264
                    _log (LOG_DEBUG,
265
                         "%s: attempting to negotiate SLI when state != ICCN\n",
265
                         "%s: attempting to negotiate SLI when state != ICCN\n",
266
                         __FUNCTION__);
266
                         __FUNCTION__);
267
                return -EINVAL;
267
                return -EINVAL;
Lines 271-277 Link Here
271
            if (t->state != SCCCN)
271
            if (t->state != SCCCN)
272
            {
272
            {
273
                if (DEBUG)
273
                if (DEBUG)
274
                    log (LOG_DEBUG,
274
                    _log (LOG_DEBUG,
275
                         "%s: attempting to negotiate OCRP on tunnel!=SCCCN\n",
275
                         "%s: attempting to negotiate OCRP on tunnel!=SCCCN\n",
276
                         __FUNCTION__);
276
                         __FUNCTION__);
277
                return -EINVAL;
277
                return -EINVAL;
Lines 279-285 Link Here
279
            if (c->state != OCRQ)
279
            if (c->state != OCRQ)
280
            {
280
            {
281
                if (DEBUG)
281
                if (DEBUG)
282
                    log (LOG_DEBUG,
282
                    _log (LOG_DEBUG,
283
                         "%s: attempting to negotiate OCRP when state != OCRQ\n",
283
                         "%s: attempting to negotiate OCRP when state != OCRQ\n",
284
                         __FUNCTION__);
284
                         __FUNCTION__);
285
                return -EINVAL;
285
                return -EINVAL;
Lines 290-296 Link Here
290
            if (c->state != OCRQ)
290
            if (c->state != OCRQ)
291
            {
291
            {
292
                if (DEBUG)
292
                if (DEBUG)
293
                    log (LOG_DEBUG,
293
                    _log (LOG_DEBUG,
294
                         "%s: attempting to negotiate OCCN when state != OCRQ\n",
294
                         "%s: attempting to negotiate OCCN when state != OCRQ\n",
295
                         __FUNCTION__);
295
                         __FUNCTION__);
296
                return -EINVAL;
296
                return -EINVAL;
Lines 301-307 Link Here
301
        case Hello:
301
        case Hello:
302
            break;
302
            break;
303
        default:
303
        default:
304
            log (LOG_WARN, "%s: i don't know how to handle %s messages\n",
304
            _log (LOG_WARN, "%s: i don't know how to handle %s messages\n",
305
                 __FUNCTION__, msgtypes[c->msgtype]);
305
                 __FUNCTION__, msgtypes[c->msgtype]);
306
            return -EINVAL;
306
            return -EINVAL;
307
        }
307
        }
Lines 313-324 Link Here
313
        if (debug_avp)
313
        if (debug_avp)
314
        {
314
        {
315
            if (DEBUG)
315
            if (DEBUG)
316
                log (LOG_DEBUG, "%s: new incoming call\n", __FUNCTION__);
316
                _log (LOG_DEBUG, "%s: new incoming call\n", __FUNCTION__);
317
        }
317
        }
318
        tmp = new_call (t);
318
        tmp = new_call (t);
319
        if (!tmp)
319
        if (!tmp)
320
        {
320
        {
321
            log (LOG_WARN, "%s: unable to create new call\n", __FUNCTION__);
321
            _log (LOG_WARN, "%s: unable to create new call\n", __FUNCTION__);
322
            return -EINVAL;
322
            return -EINVAL;
323
        }
323
        }
324
        tmp->next = t->call_head;
324
        tmp->next = t->call_head;
Lines 345-351 Link Here
345
        if (size < 0)
345
        if (size < 0)
346
        {
346
        {
347
            if (DEBUG)
347
            if (DEBUG)
348
                log (LOG_DEBUG, "%s: Random vector too small (%d < 0)\n",
348
                _log (LOG_DEBUG, "%s: Random vector too small (%d < 0)\n",
349
                     __FUNCTION__, size);
349
                     __FUNCTION__, size);
350
            wrong_length (c, "Random Vector", 6, datalen, 1);
350
            wrong_length (c, "Random Vector", 6, datalen, 1);
351
            return -EINVAL;
351
            return -EINVAL;
Lines 353-366 Link Here
353
        if (size > MAX_VECTOR_SIZE)
353
        if (size > MAX_VECTOR_SIZE)
354
        {
354
        {
355
            if (DEBUG)
355
            if (DEBUG)
356
                log (LOG_DEBUG, "%s: Random vector too large (%d > %d)\n",
356
                _log (LOG_DEBUG, "%s: Random vector too large (%d > %d)\n",
357
                     __FUNCTION__, datalen, MAX_VECTOR_SIZE);
357
                     __FUNCTION__, datalen, MAX_VECTOR_SIZE);
358
            wrong_length (c, "Random Vector", 6, datalen, 1);
358
            wrong_length (c, "Random Vector", 6, datalen, 1);
359
            return -EINVAL;
359
            return -EINVAL;
360
        }
360
        }
361
    }
361
    }
362
    if (debug_avp)
362
    if (debug_avp)
363
        log (LOG_DEBUG, "%s: Random Vector of %d octets\n", __FUNCTION__,
363
        _log (LOG_DEBUG, "%s: Random Vector of %d octets\n", __FUNCTION__,
364
             size);
364
             size);
365
    t->chal_us.vector = (unsigned char *) &raw[3];
365
    t->chal_us.vector = (unsigned char *) &raw[3];
366
    t->chal_us.vector_len = size;
366
    t->chal_us.vector_len = size;
Lines 383-389 Link Here
383
    if (debug_avp)
383
    if (debug_avp)
384
    {
384
    {
385
        if (DEBUG)
385
        if (DEBUG)
386
            log (LOG_DEBUG, "%s : Ignoring AVP\n", __FUNCTION__);
386
            _log (LOG_DEBUG, "%s : Ignoring AVP\n", __FUNCTION__);
387
    }
387
    }
388
    return 0;
388
    return 0;
389
}
389
}
Lines 396-402 Link Here
396
        if (datalen != 6)
396
        if (datalen != 6)
397
        {
397
        {
398
            if (DEBUG)
398
            if (DEBUG)
399
                log (LOG_DEBUG,
399
                _log (LOG_DEBUG,
400
                     "%s: avp is incorrect size.  %d != 6\n", __FUNCTION__,
400
                     "%s: avp is incorrect size.  %d != 6\n", __FUNCTION__,
401
                     datalen);
401
                     datalen);
402
            wrong_length (c, "Sequencing Required", 6, datalen, 1);
402
            wrong_length (c, "Sequencing Required", 6, datalen, 1);
Lines 408-414 Link Here
408
            break;
408
            break;
409
        default:
409
        default:
410
            if (DEBUG)
410
            if (DEBUG)
411
                log (LOG_DEBUG,
411
                _log (LOG_DEBUG,
412
                     "%s: sequencing required not appropriate for %s!\n",
412
                     "%s: sequencing required not appropriate for %s!\n",
413
                     __FUNCTION__, msgtypes[c->msgtype]);
413
                     __FUNCTION__, msgtypes[c->msgtype]);
414
            return -EINVAL;
414
            return -EINVAL;
Lines 418-424 Link Here
418
    if (debug_avp)
418
    if (debug_avp)
419
    {
419
    {
420
        if (DEBUG)
420
        if (DEBUG)
421
            log (LOG_DEBUG, "%s: peer requires sequencing.\n", __FUNCTION__);
421
            _log (LOG_DEBUG, "%s: peer requires sequencing.\n", __FUNCTION__);
422
    }
422
    }
423
    c->seq_reqd = -1;
423
    c->seq_reqd = -1;
424
    return 0;
424
    return 0;
Lines 441-447 Link Here
441
        if (datalen < 10)
441
        if (datalen < 10)
442
        {
442
        {
443
            if (DEBUG)
443
            if (DEBUG)
444
                log (LOG_DEBUG,
444
                _log (LOG_DEBUG,
445
                     "%s: avp is incorrect size.  %d < 10\n", __FUNCTION__,
445
                     "%s: avp is incorrect size.  %d < 10\n", __FUNCTION__,
446
                     datalen);
446
                     datalen);
447
            wrong_length (c, "Result Code", 10, datalen, 1);
447
            wrong_length (c, "Result Code", 10, datalen, 1);
Lines 454-460 Link Here
454
            break;
454
            break;
455
        default:
455
        default:
456
            if (DEBUG)
456
            if (DEBUG)
457
                log (LOG_DEBUG,
457
                _log (LOG_DEBUG,
458
                     "%s: result code not appropriate for %s.  Ignoring.\n",
458
                     "%s: result code not appropriate for %s.  Ignoring.\n",
459
                     __FUNCTION__, msgtypes[c->msgtype]);
459
                     __FUNCTION__, msgtypes[c->msgtype]);
460
            return 0;
460
            return 0;
Lines 466-472 Link Here
466
    if ((c->msgtype == StopCCN) && ((result > 7) || (result < 1)))
466
    if ((c->msgtype == StopCCN) && ((result > 7) || (result < 1)))
467
    {
467
    {
468
        if (DEBUG)
468
        if (DEBUG)
469
            log (LOG_DEBUG,
469
            _log (LOG_DEBUG,
470
                 "%s: result code out of range (%d %d %d).  Ignoring.\n",
470
                 "%s: result code out of range (%d %d %d).  Ignoring.\n",
471
                 __FUNCTION__, result, error, datalen);
471
                 __FUNCTION__, result, error, datalen);
472
        return 0;
472
        return 0;
Lines 475-481 Link Here
475
    if ((c->msgtype == CDN) && ((result > 11) || (result < 1)))
475
    if ((c->msgtype == CDN) && ((result > 11) || (result < 1)))
476
    {
476
    {
477
        if (DEBUG)
477
        if (DEBUG)
478
            log (LOG_DEBUG,
478
            _log (LOG_DEBUG,
479
                 "%s: result code out of range (%d %d %d).  Ignoring.\n",
479
                 "%s: result code out of range (%d %d %d).  Ignoring.\n",
480
                 __FUNCTION__, result, error, datalen);
480
                 __FUNCTION__, result, error, datalen);
481
        return 0;
481
        return 0;
Lines 488-501 Link Here
488
    {
488
    {
489
        if (DEBUG && (c->msgtype == StopCCN))
489
        if (DEBUG && (c->msgtype == StopCCN))
490
        {
490
        {
491
            log (LOG_DEBUG,
491
            _log (LOG_DEBUG,
492
                 "%s: peer closing for reason %d (%s), error = %d (%s)\n",
492
                 "%s: peer closing for reason %d (%s), error = %d (%s)\n",
493
                 __FUNCTION__, result, stopccn_result_codes[result], error,
493
                 __FUNCTION__, result, stopccn_result_codes[result], error,
494
                 c->errormsg);
494
                 c->errormsg);
495
        }
495
        }
496
        else
496
        else
497
        {
497
        {
498
            log (LOG_DEBUG,
498
            _log (LOG_DEBUG,
499
                 "%s: peer closing for reason %d (%s), error = %d (%s)\n",
499
                 "%s: peer closing for reason %d (%s), error = %d (%s)\n",
500
                 __FUNCTION__, result, cdn_result_codes[result], error,
500
                 __FUNCTION__, result, cdn_result_codes[result], error,
501
                 c->errormsg);
501
                 c->errormsg);
Lines 520-526 Link Here
520
        if (datalen != 8)
520
        if (datalen != 8)
521
        {
521
        {
522
            if (DEBUG)
522
            if (DEBUG)
523
                log (LOG_DEBUG,
523
                _log (LOG_DEBUG,
524
                     "%s: avp is incorrect size.  %d != 8\n", __FUNCTION__,
524
                     "%s: avp is incorrect size.  %d != 8\n", __FUNCTION__,
525
                     datalen);
525
                     datalen);
526
            wrong_length (c, "Protocol Version", 8, datalen, 1);
526
            wrong_length (c, "Protocol Version", 8, datalen, 1);
Lines 533-539 Link Here
533
            break;
533
            break;
534
        default:
534
        default:
535
            if (DEBUG)
535
            if (DEBUG)
536
                log (LOG_DEBUG,
536
                _log (LOG_DEBUG,
537
                     "%s: protocol version not appropriate for %s.  Ignoring.\n",
537
                     "%s: protocol version not appropriate for %s.  Ignoring.\n",
538
                     __FUNCTION__, msgtypes[c->msgtype]);
538
                     __FUNCTION__, msgtypes[c->msgtype]);
539
            return 0;
539
            return 0;
Lines 544-550 Link Here
544
    if (debug_avp)
544
    if (debug_avp)
545
    {
545
    {
546
        if (DEBUG)
546
        if (DEBUG)
547
            log (LOG_DEBUG,
547
            _log (LOG_DEBUG,
548
                 "%s: peer is using version %d, revision %d.\n", __FUNCTION__,
548
                 "%s: peer is using version %d, revision %d.\n", __FUNCTION__,
549
                 (ver >> 8), ver & 0xFF);
549
                 (ver >> 8), ver & 0xFF);
550
    }
550
    }
Lines 572-578 Link Here
572
            break;
572
            break;
573
        default:
573
        default:
574
            if (DEBUG)
574
            if (DEBUG)
575
                log (LOG_DEBUG,
575
                _log (LOG_DEBUG,
576
                     "%s: framing capabilities not appropriate for %s.  Ignoring.\n",
576
                     "%s: framing capabilities not appropriate for %s.  Ignoring.\n",
577
                     __FUNCTION__, msgtypes[c->msgtype]);
577
                     __FUNCTION__, msgtypes[c->msgtype]);
578
            return 0;
578
            return 0;
Lines 580-586 Link Here
580
        if (datalen != 10)
580
        if (datalen != 10)
581
        {
581
        {
582
            if (DEBUG)
582
            if (DEBUG)
583
                log (LOG_DEBUG,
583
                _log (LOG_DEBUG,
584
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
584
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
585
                     datalen);
585
                     datalen);
586
            wrong_length (c, "Framming Capabilities", 10, datalen, 0);
586
            wrong_length (c, "Framming Capabilities", 10, datalen, 0);
Lines 591-597 Link Here
591
    caps = ntohs (raw[4]);
591
    caps = ntohs (raw[4]);
592
    if (debug_avp)
592
    if (debug_avp)
593
        if (DEBUG)
593
        if (DEBUG)
594
            log (LOG_DEBUG,
594
            _log (LOG_DEBUG,
595
                 "%s: supported peer frames:%s%s\n", __FUNCTION__,
595
                 "%s: supported peer frames:%s%s\n", __FUNCTION__,
596
                 caps & ASYNC_FRAMING ? " async" : "",
596
                 caps & ASYNC_FRAMING ? " async" : "",
597
                 caps & SYNC_FRAMING ? " sync" : "");
597
                 caps & SYNC_FRAMING ? " sync" : "");
Lines 618-624 Link Here
618
            break;
618
            break;
619
        default:
619
        default:
620
            if (DEBUG)
620
            if (DEBUG)
621
                log (LOG_DEBUG,
621
                _log (LOG_DEBUG,
622
                     "%s: bearer capabilities not appropriate for message %s.  Ignoring.\n",
622
                     "%s: bearer capabilities not appropriate for message %s.  Ignoring.\n",
623
                     __FUNCTION__, msgtypes[c->msgtype]);
623
                     __FUNCTION__, msgtypes[c->msgtype]);
624
            return 0;
624
            return 0;
Lines 626-632 Link Here
626
        if (datalen != 10)
626
        if (datalen != 10)
627
        {
627
        {
628
            if (DEBUG)
628
            if (DEBUG)
629
                log (LOG_DEBUG,
629
                _log (LOG_DEBUG,
630
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
630
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
631
                     datalen);
631
                     datalen);
632
            wrong_length (c, "Bearer Capabilities", 10, datalen, 0);
632
            wrong_length (c, "Bearer Capabilities", 10, datalen, 0);
Lines 639-645 Link Here
639
    {
639
    {
640
        if (DEBUG)
640
        if (DEBUG)
641
        {
641
        {
642
            log (LOG_DEBUG,
642
            _log (LOG_DEBUG,
643
                 "%s: supported peer bearers:%s%s\n",
643
                 "%s: supported peer bearers:%s%s\n",
644
                 __FUNCTION__,
644
                 __FUNCTION__,
645
                 caps & ANALOG_BEARER ? " analog" : "",
645
                 caps & ANALOG_BEARER ? " analog" : "",
Lines 673-679 Link Here
673
            break;
673
            break;
674
        default:
674
        default:
675
            if (DEBUG)
675
            if (DEBUG)
676
                log (LOG_DEBUG,
676
                _log (LOG_DEBUG,
677
                     "%s: firmware revision not appropriate for message %s.  Ignoring.\n",
677
                     "%s: firmware revision not appropriate for message %s.  Ignoring.\n",
678
                     __FUNCTION__, msgtypes[c->msgtype]);
678
                     __FUNCTION__, msgtypes[c->msgtype]);
679
            return 0;
679
            return 0;
Lines 681-687 Link Here
681
        if (datalen != 8)
681
        if (datalen != 8)
682
        {
682
        {
683
            if (DEBUG)
683
            if (DEBUG)
684
                log (LOG_DEBUG,
684
                _log (LOG_DEBUG,
685
                     "%s: avp is incorrect size.  %d != 8\n", __FUNCTION__,
685
                     "%s: avp is incorrect size.  %d != 8\n", __FUNCTION__,
686
                     datalen);
686
                     datalen);
687
            wrong_length (c, "Firmware Revision", 8, datalen, 0);
687
            wrong_length (c, "Firmware Revision", 8, datalen, 0);
Lines 693-699 Link Here
693
    if (debug_avp)
693
    if (debug_avp)
694
    {
694
    {
695
        if (DEBUG)
695
        if (DEBUG)
696
            log (LOG_DEBUG,
696
            _log (LOG_DEBUG,
697
                 "%s: peer reports firmware version %d (0x%.4x)\n",
697
                 "%s: peer reports firmware version %d (0x%.4x)\n",
698
                 __FUNCTION__, ver, ver);
698
                 __FUNCTION__, ver, ver);
699
    }
699
    }
Lines 720-726 Link Here
720
            break;
720
            break;
721
        default:
721
        default:
722
            if (DEBUG)
722
            if (DEBUG)
723
                log (LOG_DEBUG,
723
                _log (LOG_DEBUG,
724
                     "%s: bearer type not appropriate for message %s.  Ignoring.\n",
724
                     "%s: bearer type not appropriate for message %s.  Ignoring.\n",
725
                     __FUNCTION__, msgtypes[c->msgtype]);
725
                     __FUNCTION__, msgtypes[c->msgtype]);
726
            return 0;
726
            return 0;
Lines 728-734 Link Here
728
        if (datalen != 10)
728
        if (datalen != 10)
729
        {
729
        {
730
            if (DEBUG)
730
            if (DEBUG)
731
                log (LOG_DEBUG,
731
                _log (LOG_DEBUG,
732
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
732
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
733
                     datalen);
733
                     datalen);
734
            wrong_length (c, "Bearer Type", 10, datalen, 0);
734
            wrong_length (c, "Bearer Type", 10, datalen, 0);
Lines 740-746 Link Here
740
    if (debug_avp)
740
    if (debug_avp)
741
    {
741
    {
742
        if (DEBUG)
742
        if (DEBUG)
743
            log (LOG_DEBUG,
743
            _log (LOG_DEBUG,
744
                 "%s: peer bears:%s\n", __FUNCTION__,
744
                 "%s: peer bears:%s\n", __FUNCTION__,
745
                 b & ANALOG_BEARER ? " analog" : "digital");
745
                 b & ANALOG_BEARER ? " analog" : "digital");
746
    }
746
    }
Lines 767-773 Link Here
767
            break;
767
            break;
768
        default:
768
        default:
769
            if (DEBUG)
769
            if (DEBUG)
770
                log (LOG_DEBUG,
770
                _log (LOG_DEBUG,
771
                     "%s: frame type not appropriate for message %s.  Ignoring.\n",
771
                     "%s: frame type not appropriate for message %s.  Ignoring.\n",
772
                     __FUNCTION__, msgtypes[c->msgtype]);
772
                     __FUNCTION__, msgtypes[c->msgtype]);
773
            return 0;
773
            return 0;
Lines 775-781 Link Here
775
        if (datalen != 10)
775
        if (datalen != 10)
776
        {
776
        {
777
            if (DEBUG)
777
            if (DEBUG)
778
                log (LOG_DEBUG,
778
                _log (LOG_DEBUG,
779
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
779
                     "%s: avp is incorrect size.  %d != 10\n", __FUNCTION__,
780
                     datalen);
780
                     datalen);
781
            wrong_length (c, "Frame Type", 10, datalen, 0);
781
            wrong_length (c, "Frame Type", 10, datalen, 0);
Lines 787-793 Link Here
787
    if (debug_avp)
787
    if (debug_avp)
788
    {
788
    {
789
        if (DEBUG)
789
        if (DEBUG)
790
            log (LOG_DEBUG,
790
            _log (LOG_DEBUG,
791
                 "%s: peer uses:%s frames\n", __FUNCTION__,
791
                 "%s: peer uses:%s frames\n", __FUNCTION__,
792
                 b & ASYNC_FRAMING ? " async" : "sync");
792
                 b & ASYNC_FRAMING ? " async" : "sync");
793
    }
793
    }
Lines 813-819 Link Here
813
            break;
813
            break;
814
        default:
814
        default:
815
            if (DEBUG)
815
            if (DEBUG)
816
                log (LOG_DEBUG,
816
                _log (LOG_DEBUG,
817
                     "%s: hostname not appropriate for message %s.  Ignoring.\n",
817
                     "%s: hostname not appropriate for message %s.  Ignoring.\n",
818
                     __FUNCTION__, msgtypes[c->msgtype]);
818
                     __FUNCTION__, msgtypes[c->msgtype]);
819
            return 0;
819
            return 0;
Lines 821-827 Link Here
821
        if (datalen < 6)
821
        if (datalen < 6)
822
        {
822
        {
823
            if (DEBUG)
823
            if (DEBUG)
824
                log (LOG_DEBUG,
824
                _log (LOG_DEBUG,
825
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
825
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
826
                     datalen);
826
                     datalen);
827
            wrong_length (c, "Hostname", 6, datalen, 1);
827
            wrong_length (c, "Hostname", 6, datalen, 1);
Lines 833-839 Link Here
833
    if (size > MAXSTRLEN - 1)
833
    if (size > MAXSTRLEN - 1)
834
    {
834
    {
835
        if (DEBUG)
835
        if (DEBUG)
836
            log (LOG_DEBUG, "%s: truncating reported hostname (size is %d)\n",
836
            _log (LOG_DEBUG, "%s: truncating reported hostname (size is %d)\n",
837
                 __FUNCTION__, size);
837
                 __FUNCTION__, size);
838
        size = MAXSTRLEN - 1;
838
        size = MAXSTRLEN - 1;
839
    }
839
    }
Lines 841-847 Link Here
841
    if (debug_avp)
841
    if (debug_avp)
842
    {
842
    {
843
        if (DEBUG)
843
        if (DEBUG)
844
            log (LOG_DEBUG,
844
            _log (LOG_DEBUG,
845
                 "%s: peer reports hostname '%s'\n", __FUNCTION__,
845
                 "%s: peer reports hostname '%s'\n", __FUNCTION__,
846
                 t->hostname);
846
                 t->hostname);
847
    }
847
    }
Lines 866-872 Link Here
866
            break;
866
            break;
867
        default:
867
        default:
868
            if (DEBUG)
868
            if (DEBUG)
869
                log (LOG_DEBUG,
869
                _log (LOG_DEBUG,
870
                     "%s: dialing number not appropriate for message %s.  Ignoring.\n",
870
                     "%s: dialing number not appropriate for message %s.  Ignoring.\n",
871
                     __FUNCTION__, msgtypes[c->msgtype]);
871
                     __FUNCTION__, msgtypes[c->msgtype]);
872
            return 0;
872
            return 0;
Lines 874-880 Link Here
874
        if (datalen < 6)
874
        if (datalen < 6)
875
        {
875
        {
876
            if (DEBUG)
876
            if (DEBUG)
877
                log (LOG_DEBUG,
877
                _log (LOG_DEBUG,
878
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
878
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
879
                     datalen);
879
                     datalen);
880
            wrong_length (c, "Dialing Number", 6, datalen, 1);
880
            wrong_length (c, "Dialing Number", 6, datalen, 1);
Lines 886-892 Link Here
886
    if (size > MAXSTRLEN - 1)
886
    if (size > MAXSTRLEN - 1)
887
    {
887
    {
888
        if (DEBUG)
888
        if (DEBUG)
889
            log (LOG_DEBUG,
889
            _log (LOG_DEBUG,
890
                 "%s: truncating reported dialing number (size is %d)\n",
890
                 "%s: truncating reported dialing number (size is %d)\n",
891
                 __FUNCTION__, size);
891
                 __FUNCTION__, size);
892
        size = MAXSTRLEN - 1;
892
        size = MAXSTRLEN - 1;
Lines 895-901 Link Here
895
    if (debug_avp)
895
    if (debug_avp)
896
    {
896
    {
897
        if (DEBUG)
897
        if (DEBUG)
898
            log (LOG_DEBUG,
898
            _log (LOG_DEBUG,
899
                 "%s: peer reports dialing number '%s'\n", __FUNCTION__,
899
                 "%s: peer reports dialing number '%s'\n", __FUNCTION__,
900
                 t->call_head->dialing);
900
                 t->call_head->dialing);
901
    }
901
    }
Lines 921-927 Link Here
921
            break;
921
            break;
922
        default:
922
        default:
923
            if (DEBUG)
923
            if (DEBUG)
924
                log (LOG_DEBUG,
924
                _log (LOG_DEBUG,
925
                     "%s: dialed number not appropriate for message %s.  Ignoring.\n",
925
                     "%s: dialed number not appropriate for message %s.  Ignoring.\n",
926
                     __FUNCTION__, msgtypes[c->msgtype]);
926
                     __FUNCTION__, msgtypes[c->msgtype]);
927
            return 0;
927
            return 0;
Lines 929-935 Link Here
929
        if (datalen < 6)
929
        if (datalen < 6)
930
        {
930
        {
931
            if (DEBUG)
931
            if (DEBUG)
932
                log (LOG_DEBUG,
932
                _log (LOG_DEBUG,
933
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
933
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
934
                     datalen);
934
                     datalen);
935
            wrong_length (c, "Dialed Number", 6, datalen, 1);
935
            wrong_length (c, "Dialed Number", 6, datalen, 1);
Lines 941-947 Link Here
941
    if (size > MAXSTRLEN - 1)
941
    if (size > MAXSTRLEN - 1)
942
    {
942
    {
943
        if (DEBUG)
943
        if (DEBUG)
944
            log (LOG_DEBUG,
944
            _log (LOG_DEBUG,
945
                 "%s: truncating reported dialed number (size is %d)\n",
945
                 "%s: truncating reported dialed number (size is %d)\n",
946
                 __FUNCTION__, size);
946
                 __FUNCTION__, size);
947
        size = MAXSTRLEN - 1;
947
        size = MAXSTRLEN - 1;
Lines 950-956 Link Here
950
    if (debug_avp)
950
    if (debug_avp)
951
    {
951
    {
952
        if (DEBUG)
952
        if (DEBUG)
953
            log (LOG_DEBUG,
953
            _log (LOG_DEBUG,
954
                 "%s: peer reports dialed number '%s'\n", __FUNCTION__,
954
                 "%s: peer reports dialed number '%s'\n", __FUNCTION__,
955
                 t->call_head->dialed);
955
                 t->call_head->dialed);
956
    }
956
    }
Lines 976-982 Link Here
976
            break;
976
            break;
977
        default:
977
        default:
978
            if (DEBUG)
978
            if (DEBUG)
979
                log (LOG_DEBUG,
979
                _log (LOG_DEBUG,
980
                     "%s: sub_address not appropriate for message %s.  Ignoring.\n",
980
                     "%s: sub_address not appropriate for message %s.  Ignoring.\n",
981
                     __FUNCTION__, msgtypes[c->msgtype]);
981
                     __FUNCTION__, msgtypes[c->msgtype]);
982
            return 0;
982
            return 0;
Lines 984-990 Link Here
984
        if (datalen < 6)
984
        if (datalen < 6)
985
        {
985
        {
986
            if (DEBUG)
986
            if (DEBUG)
987
                log (LOG_DEBUG,
987
                _log (LOG_DEBUG,
988
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
988
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
989
                     datalen);
989
                     datalen);
990
            wrong_length (c, "Sub-address", 6, datalen, 1);
990
            wrong_length (c, "Sub-address", 6, datalen, 1);
Lines 996-1002 Link Here
996
    if (size > MAXSTRLEN - 1)
996
    if (size > MAXSTRLEN - 1)
997
    {
997
    {
998
        if (DEBUG)
998
        if (DEBUG)
999
            log (LOG_DEBUG,
999
            _log (LOG_DEBUG,
1000
                 "%s: truncating reported sub address (size is %d)\n",
1000
                 "%s: truncating reported sub address (size is %d)\n",
1001
                 __FUNCTION__, size);
1001
                 __FUNCTION__, size);
1002
        size = MAXSTRLEN - 1;
1002
        size = MAXSTRLEN - 1;
Lines 1005-1011 Link Here
1005
    if (debug_avp)
1005
    if (debug_avp)
1006
    {
1006
    {
1007
        if (DEBUG)
1007
        if (DEBUG)
1008
            log (LOG_DEBUG,
1008
            _log (LOG_DEBUG,
1009
                 "%s: peer reports subaddress '%s'\n", __FUNCTION__,
1009
                 "%s: peer reports subaddress '%s'\n", __FUNCTION__,
1010
                 t->call_head->subaddy);
1010
                 t->call_head->subaddy);
1011
    }
1011
    }
Lines 1030-1036 Link Here
1030
            break;
1030
            break;
1031
        default:
1031
        default:
1032
            if (DEBUG)
1032
            if (DEBUG)
1033
                log (LOG_DEBUG,
1033
                _log (LOG_DEBUG,
1034
                     "%s: vendor not appropriate for message %s.  Ignoring.\n",
1034
                     "%s: vendor not appropriate for message %s.  Ignoring.\n",
1035
                     __FUNCTION__, msgtypes[c->msgtype]);
1035
                     __FUNCTION__, msgtypes[c->msgtype]);
1036
            return 0;
1036
            return 0;
Lines 1038-1044 Link Here
1038
        if (datalen < 6)
1038
        if (datalen < 6)
1039
        {
1039
        {
1040
            if (DEBUG)
1040
            if (DEBUG)
1041
                log (LOG_DEBUG,
1041
                _log (LOG_DEBUG,
1042
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
1042
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
1043
                     datalen);
1043
                     datalen);
1044
            wrong_length (c, "Vendor", 6, datalen, 1);
1044
            wrong_length (c, "Vendor", 6, datalen, 1);
Lines 1050-1056 Link Here
1050
    if (size > MAXSTRLEN - 1)
1050
    if (size > MAXSTRLEN - 1)
1051
    {
1051
    {
1052
        if (DEBUG)
1052
        if (DEBUG)
1053
            log (LOG_DEBUG, "%s: truncating reported vendor (size is %d)\n",
1053
            _log (LOG_DEBUG, "%s: truncating reported vendor (size is %d)\n",
1054
                 __FUNCTION__, size);
1054
                 __FUNCTION__, size);
1055
        size = MAXSTRLEN - 1;
1055
        size = MAXSTRLEN - 1;
1056
    }
1056
    }
Lines 1058-1064 Link Here
1058
    if (debug_avp)
1058
    if (debug_avp)
1059
    {
1059
    {
1060
        if (DEBUG)
1060
        if (DEBUG)
1061
            log (LOG_DEBUG,
1061
            _log (LOG_DEBUG,
1062
                 "%s: peer reports vendor '%s'\n", __FUNCTION__, t->vendor);
1062
                 "%s: peer reports vendor '%s'\n", __FUNCTION__, t->vendor);
1063
    }
1063
    }
1064
    return 0;
1064
    return 0;
Lines 1081-1087 Link Here
1081
            break;
1081
            break;
1082
        default:
1082
        default:
1083
            if (DEBUG)
1083
            if (DEBUG)
1084
                log (LOG_DEBUG,
1084
                _log (LOG_DEBUG,
1085
                     "%s: challenge not appropriate for message %s.  Ignoring.\n",
1085
                     "%s: challenge not appropriate for message %s.  Ignoring.\n",
1086
                     __FUNCTION__, msgtypes[c->msgtype]);
1086
                     __FUNCTION__, msgtypes[c->msgtype]);
1087
            return 0;
1087
            return 0;
Lines 1089-1095 Link Here
1089
        if (datalen < 6)
1089
        if (datalen < 6)
1090
        {
1090
        {
1091
            if (DEBUG)
1091
            if (DEBUG)
1092
                log (LOG_DEBUG,
1092
                _log (LOG_DEBUG,
1093
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
1093
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
1094
                     datalen);
1094
                     datalen);
1095
            wrong_length (c, "challenge", 6, datalen, 1);
1095
            wrong_length (c, "challenge", 6, datalen, 1);
Lines 1103-1109 Link Here
1103
    size -= sizeof (struct avp_hdr);
1103
    size -= sizeof (struct avp_hdr);
1104
    /* if (size != MD_SIG_SIZE)
1104
    /* if (size != MD_SIG_SIZE)
1105
    {
1105
    {
1106
        log (LOG_DEBUG, "%s: Challenge is not the right length (%d != %d)\n",
1106
        _log (LOG_DEBUG, "%s: Challenge is not the right length (%d != %d)\n",
1107
             __FUNCTION__, size, MD_SIG_SIZE);
1107
             __FUNCTION__, size, MD_SIG_SIZE);
1108
        return -EINVAL;
1108
        return -EINVAL;
1109
    } */
1109
    } */
Lines 1117-1123 Link Here
1117
    t->chal_us.state = STATE_CHALLENGED;
1117
    t->chal_us.state = STATE_CHALLENGED;
1118
    if (debug_avp)
1118
    if (debug_avp)
1119
    {
1119
    {
1120
        log (LOG_DEBUG, "%s: challenge avp found\n", __FUNCTION__);
1120
        _log (LOG_DEBUG, "%s: challenge avp found\n", __FUNCTION__);
1121
    }
1121
    }
1122
    return 0;
1122
    return 0;
1123
}
1123
}
Lines 1139-1145 Link Here
1139
            break;
1139
            break;
1140
        default:
1140
        default:
1141
            if (DEBUG)
1141
            if (DEBUG)
1142
                log (LOG_DEBUG,
1142
                _log (LOG_DEBUG,
1143
                     "%s: challenge response not appropriate for message %s.  Ignoring.\n",
1143
                     "%s: challenge response not appropriate for message %s.  Ignoring.\n",
1144
                     __FUNCTION__, msgtypes[c->msgtype]);
1144
                     __FUNCTION__, msgtypes[c->msgtype]);
1145
            return 0;
1145
            return 0;
Lines 1147-1153 Link Here
1147
        if (datalen < 6)
1147
        if (datalen < 6)
1148
        {
1148
        {
1149
            if (DEBUG)
1149
            if (DEBUG)
1150
                log (LOG_DEBUG,
1150
                _log (LOG_DEBUG,
1151
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
1151
                     "%s: avp is too small.  %d < 6\n", __FUNCTION__,
1152
                     datalen);
1152
                     datalen);
1153
            wrong_length (c, "challenge", 6, datalen, 1);
1153
            wrong_length (c, "challenge", 6, datalen, 1);
Lines 1159-1165 Link Here
1159
    size -= sizeof (struct avp_hdr);
1159
    size -= sizeof (struct avp_hdr);
1160
    if (size != MD_SIG_SIZE)
1160
    if (size != MD_SIG_SIZE)
1161
    {
1161
    {
1162
        log (LOG_DEBUG, "%s: Challenge is not the right length (%d != %d)\n",
1162
        _log (LOG_DEBUG, "%s: Challenge is not the right length (%d != %d)\n",
1163
             __FUNCTION__, size, MD_SIG_SIZE);
1163
             __FUNCTION__, size, MD_SIG_SIZE);
1164
        return -EINVAL;
1164
        return -EINVAL;
1165
    }
1165
    }
Lines 1167-1173 Link Here
1167
    bcopy (&raw[3], t->chal_them.reply, MD_SIG_SIZE);
1167
    bcopy (&raw[3], t->chal_them.reply, MD_SIG_SIZE);
1168
    if (debug_avp)
1168
    if (debug_avp)
1169
    {
1169
    {
1170
        log (LOG_DEBUG, "%s: Challenge reply found\n", __FUNCTION__);
1170
        _log (LOG_DEBUG, "%s: Challenge reply found\n", __FUNCTION__);
1171
    }
1171
    }
1172
    return 0;
1172
    return 0;
1173
}
1173
}
Lines 1191-1197 Link Here
1191
            break;
1191
            break;
1192
        default:
1192
        default:
1193
            if (DEBUG)
1193
            if (DEBUG)
1194
                log (LOG_DEBUG,
1194
                _log (LOG_DEBUG,
1195
                     "%s: tunnel ID not appropriate for message %s.  Ignoring.\n",
1195
                     "%s: tunnel ID not appropriate for message %s.  Ignoring.\n",
1196
                     __FUNCTION__, msgtypes[c->msgtype]);
1196
                     __FUNCTION__, msgtypes[c->msgtype]);
1197
            return 0;
1197
            return 0;
Lines 1199-1205 Link Here
1199
        if (datalen != 8)
1199
        if (datalen != 8)
1200
        {
1200
        {
1201
            if (DEBUG)
1201
            if (DEBUG)
1202
                log (LOG_DEBUG,
1202
                _log (LOG_DEBUG,
1203
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1203
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1204
                     datalen);
1204
                     datalen);
1205
            wrong_length (c, "Assigned Tunnel ID", 8, datalen, 0);
1205
            wrong_length (c, "Assigned Tunnel ID", 8, datalen, 0);
Lines 1218-1224 Link Here
1218
    if (debug_avp)
1218
    if (debug_avp)
1219
    {
1219
    {
1220
        if (DEBUG)
1220
        if (DEBUG)
1221
            log (LOG_DEBUG,
1221
            _log (LOG_DEBUG,
1222
                 "%s: using peer's tunnel %d\n", __FUNCTION__,
1222
                 "%s: using peer's tunnel %d\n", __FUNCTION__,
1223
                 ntohs (raw[3]));
1223
                 ntohs (raw[3]));
1224
    }
1224
    }
Lines 1246-1252 Link Here
1246
        case OCRQ:
1246
        case OCRQ:
1247
        default:
1247
        default:
1248
            if (DEBUG)
1248
            if (DEBUG)
1249
                log (LOG_DEBUG,
1249
                _log (LOG_DEBUG,
1250
                     "%s: call ID not appropriate for message %s.  Ignoring.\n",
1250
                     "%s: call ID not appropriate for message %s.  Ignoring.\n",
1251
                     __FUNCTION__, msgtypes[c->msgtype]);
1251
                     __FUNCTION__, msgtypes[c->msgtype]);
1252
            return 0;
1252
            return 0;
Lines 1254-1260 Link Here
1254
        if (datalen != 8)
1254
        if (datalen != 8)
1255
        {
1255
        {
1256
            if (DEBUG)
1256
            if (DEBUG)
1257
                log (LOG_DEBUG,
1257
                _log (LOG_DEBUG,
1258
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1258
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1259
                     datalen);
1259
                     datalen);
1260
            wrong_length (c, "Assigned Call ID", 8, datalen, 0);
1260
            wrong_length (c, "Assigned Call ID", 8, datalen, 0);
Lines 1280-1292 Link Here
1280
    }
1280
    }
1281
    else
1281
    else
1282
    {
1282
    {
1283
        log (LOG_DEBUG, "%s:  Dunno what to do when it's state %s!\n",
1283
        _log (LOG_DEBUG, "%s:  Dunno what to do when it's state %s!\n",
1284
             __FUNCTION__, msgtypes[c->msgtype]);
1284
             __FUNCTION__, msgtypes[c->msgtype]);
1285
    }
1285
    }
1286
    if (debug_avp)
1286
    if (debug_avp)
1287
    {
1287
    {
1288
        if (DEBUG)
1288
        if (DEBUG)
1289
            log (LOG_DEBUG,
1289
            _log (LOG_DEBUG,
1290
                 "%s: using peer's call %d\n", __FUNCTION__, ntohs (raw[3]));
1290
                 "%s: using peer's call %d\n", __FUNCTION__, ntohs (raw[3]));
1291
    }
1291
    }
1292
    return 0;
1292
    return 0;
Lines 1313-1319 Link Here
1313
            break;
1313
            break;
1314
        default:
1314
        default:
1315
            if (DEBUG)
1315
            if (DEBUG)
1316
                log (LOG_DEBUG,
1316
                _log (LOG_DEBUG,
1317
                     "%s: packet delay not appropriate for message %s.  Ignoring.\n",
1317
                     "%s: packet delay not appropriate for message %s.  Ignoring.\n",
1318
                     __FUNCTION__, msgtypes[c->msgtype]);
1318
                     __FUNCTION__, msgtypes[c->msgtype]);
1319
            return 0;
1319
            return 0;
Lines 1321-1327 Link Here
1321
        if (datalen != 8)
1321
        if (datalen != 8)
1322
        {
1322
        {
1323
            if (DEBUG)
1323
            if (DEBUG)
1324
                log (LOG_DEBUG,
1324
                _log (LOG_DEBUG,
1325
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1325
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1326
                     datalen);
1326
                     datalen);
1327
            wrong_length (c, "Assigned Call ID", 8, datalen, 0);
1327
            wrong_length (c, "Assigned Call ID", 8, datalen, 0);
Lines 1333-1339 Link Here
1333
    if (debug_avp)
1333
    if (debug_avp)
1334
    {
1334
    {
1335
        if (DEBUG)
1335
        if (DEBUG)
1336
            log (LOG_DEBUG,
1336
            _log (LOG_DEBUG,
1337
                 "%s: peer's delay is %d 1/10's of a second\n", __FUNCTION__,
1337
                 "%s: peer's delay is %d 1/10's of a second\n", __FUNCTION__,
1338
                 ntohs (raw[3]));
1338
                 ntohs (raw[3]));
1339
    }
1339
    }
Lines 1357-1363 Link Here
1357
            break;
1357
            break;
1358
        default:
1358
        default:
1359
            if (DEBUG)
1359
            if (DEBUG)
1360
                log (LOG_DEBUG,
1360
                _log (LOG_DEBUG,
1361
                     "%s: call ID not appropriate for message %s.  Ignoring.\n",
1361
                     "%s: call ID not appropriate for message %s.  Ignoring.\n",
1362
                     __FUNCTION__, msgtypes[c->msgtype]);
1362
                     __FUNCTION__, msgtypes[c->msgtype]);
1363
            return 0;
1363
            return 0;
Lines 1366-1378 Link Here
1366
        {
1366
        {
1367
#ifdef STRICT
1367
#ifdef STRICT
1368
            if (DEBUG)
1368
            if (DEBUG)
1369
                log (LOG_DEBUG,
1369
                _log (LOG_DEBUG,
1370
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1370
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1371
                     datalen);
1371
                     datalen);
1372
            wrong_length (c, "Serial Number", 10, datalen, 0);
1372
            wrong_length (c, "Serial Number", 10, datalen, 0);
1373
            return -EINVAL;
1373
            return -EINVAL;
1374
#else
1374
#else
1375
            log (LOG_DEBUG,
1375
            _log (LOG_DEBUG,
1376
                 "%s: peer is using old style serial number.  Will be invalid.\n",
1376
                 "%s: peer is using old style serial number.  Will be invalid.\n",
1377
                 __FUNCTION__);
1377
                 __FUNCTION__);
1378
#endif
1378
#endif
Lines 1385-1391 Link Here
1385
    if (debug_avp)
1385
    if (debug_avp)
1386
    {
1386
    {
1387
        if (DEBUG)
1387
        if (DEBUG)
1388
            log (LOG_DEBUG,
1388
            _log (LOG_DEBUG,
1389
                 "%s: serial number is %d\n", __FUNCTION__,
1389
                 "%s: serial number is %d\n", __FUNCTION__,
1390
                 t->call_head->serno);
1390
                 t->call_head->serno);
1391
    }
1391
    }
Lines 1410-1416 Link Here
1410
            break;
1410
            break;
1411
        default:
1411
        default:
1412
            if (DEBUG)
1412
            if (DEBUG)
1413
                log (LOG_DEBUG,
1413
                _log (LOG_DEBUG,
1414
                     "%s: rx connect speed not appropriate for message %s.  Ignoring.\n",
1414
                     "%s: rx connect speed not appropriate for message %s.  Ignoring.\n",
1415
                     __FUNCTION__, msgtypes[c->msgtype]);
1415
                     __FUNCTION__, msgtypes[c->msgtype]);
1416
            return 0;
1416
            return 0;
Lines 1418-1424 Link Here
1418
        if (datalen != 10)
1418
        if (datalen != 10)
1419
        {
1419
        {
1420
            if (DEBUG)
1420
            if (DEBUG)
1421
                log (LOG_DEBUG,
1421
                _log (LOG_DEBUG,
1422
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1422
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1423
                     datalen);
1423
                     datalen);
1424
            wrong_length (c, "Connect Speed (RX)", 10, datalen, 0);
1424
            wrong_length (c, "Connect Speed (RX)", 10, datalen, 0);
Lines 1431-1437 Link Here
1431
    if (debug_avp)
1431
    if (debug_avp)
1432
    {
1432
    {
1433
        if (DEBUG)
1433
        if (DEBUG)
1434
            log (LOG_DEBUG,
1434
            _log (LOG_DEBUG,
1435
                 "%s: receive baud rate is %d\n", __FUNCTION__, c->rxspeed);
1435
                 "%s: receive baud rate is %d\n", __FUNCTION__, c->rxspeed);
1436
    }
1436
    }
1437
    return 0;
1437
    return 0;
Lines 1455-1461 Link Here
1455
            break;
1455
            break;
1456
        default:
1456
        default:
1457
            if (DEBUG)
1457
            if (DEBUG)
1458
                log (LOG_DEBUG,
1458
                _log (LOG_DEBUG,
1459
                     "%s: tx connect speed not appropriate for message %s.  Ignoring.\n",
1459
                     "%s: tx connect speed not appropriate for message %s.  Ignoring.\n",
1460
                     __FUNCTION__, msgtypes[c->msgtype]);
1460
                     __FUNCTION__, msgtypes[c->msgtype]);
1461
            return 0;
1461
            return 0;
Lines 1463-1469 Link Here
1463
        if (datalen != 10)
1463
        if (datalen != 10)
1464
        {
1464
        {
1465
            if (DEBUG)
1465
            if (DEBUG)
1466
                log (LOG_DEBUG,
1466
                _log (LOG_DEBUG,
1467
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1467
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1468
                     datalen);
1468
                     datalen);
1469
            wrong_length (c, "Connect Speed (tx)", 10, datalen, 0);
1469
            wrong_length (c, "Connect Speed (tx)", 10, datalen, 0);
Lines 1476-1482 Link Here
1476
    if (debug_avp)
1476
    if (debug_avp)
1477
    {
1477
    {
1478
        if (DEBUG)
1478
        if (DEBUG)
1479
            log (LOG_DEBUG,
1479
            _log (LOG_DEBUG,
1480
                 "%s: transmit baud rate is %d\n", __FUNCTION__, c->txspeed);
1480
                 "%s: transmit baud rate is %d\n", __FUNCTION__, c->txspeed);
1481
    }
1481
    }
1482
    return 0;
1482
    return 0;
Lines 1501-1507 Link Here
1501
            break;
1501
            break;
1502
        default:
1502
        default:
1503
            if (DEBUG)
1503
            if (DEBUG)
1504
                log (LOG_DEBUG,
1504
                _log (LOG_DEBUG,
1505
                     "%s: physical channel not appropriate for message %s.  Ignoring.\n",
1505
                     "%s: physical channel not appropriate for message %s.  Ignoring.\n",
1506
                     __FUNCTION__, msgtypes[c->msgtype]);
1506
                     __FUNCTION__, msgtypes[c->msgtype]);
1507
            return 0;
1507
            return 0;
Lines 1509-1515 Link Here
1509
        if (datalen != 10)
1509
        if (datalen != 10)
1510
        {
1510
        {
1511
            if (DEBUG)
1511
            if (DEBUG)
1512
                log (LOG_DEBUG,
1512
                _log (LOG_DEBUG,
1513
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1513
                     "%s: avp is wrong size.  %d != 10\n", __FUNCTION__,
1514
                     datalen);
1514
                     datalen);
1515
            wrong_length (c, "Physical Channel", 10, datalen, 0);
1515
            wrong_length (c, "Physical Channel", 10, datalen, 0);
Lines 1522-1528 Link Here
1522
    if (debug_avp)
1522
    if (debug_avp)
1523
    {
1523
    {
1524
        if (DEBUG)
1524
        if (DEBUG)
1525
            log (LOG_DEBUG,
1525
            _log (LOG_DEBUG,
1526
                 "%s: physical channel is %d\n", __FUNCTION__,
1526
                 "%s: physical channel is %d\n", __FUNCTION__,
1527
                 t->call_head->physchan);
1527
                 t->call_head->physchan);
1528
    }
1528
    }
Lines 1552-1558 Link Here
1552
            break;
1552
            break;
1553
        default:
1553
        default:
1554
            if (DEBUG)
1554
            if (DEBUG)
1555
                log (LOG_DEBUG,
1555
                _log (LOG_DEBUG,
1556
                     "%s: RWS not appropriate for message %s.  Ignoring.\n",
1556
                     "%s: RWS not appropriate for message %s.  Ignoring.\n",
1557
                     __FUNCTION__, msgtypes[c->msgtype]);
1557
                     __FUNCTION__, msgtypes[c->msgtype]);
1558
            return 0;
1558
            return 0;
Lines 1560-1566 Link Here
1560
        if (datalen != 8)
1560
        if (datalen != 8)
1561
        {
1561
        {
1562
            if (DEBUG)
1562
            if (DEBUG)
1563
                log (LOG_DEBUG,
1563
                _log (LOG_DEBUG,
1564
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1564
                     "%s: avp is wrong size.  %d != 8\n", __FUNCTION__,
1565
                     datalen);
1565
                     datalen);
1566
            wrong_length (c, "Receive Window Size", 8, datalen, 0);
1566
            wrong_length (c, "Receive Window Size", 8, datalen, 0);
Lines 1574-1580 Link Here
1574
    if (debug_avp)
1574
    if (debug_avp)
1575
    {
1575
    {
1576
        if (DEBUG)
1576
        if (DEBUG)
1577
            log (LOG_DEBUG,
1577
            _log (LOG_DEBUG,
1578
                 "%s: peer wants RWS of %d.  Will use flow control.\n",
1578
                 "%s: peer wants RWS of %d.  Will use flow control.\n",
1579
                 __FUNCTION__, t->rws);
1579
                 __FUNCTION__, t->rws);
1580
    }
1580
    }
Lines 1597-1603 Link Here
1597
    char *data = buf->start + sizeof (struct control_hdr);
1597
    char *data = buf->start + sizeof (struct control_hdr);
1598
    avp = (struct avp_hdr *) data;
1598
    avp = (struct avp_hdr *) data;
1599
    if (debug_avp)
1599
    if (debug_avp)
1600
        log (LOG_DEBUG, "%s: handling avp's for tunnel %d, call %d\n",
1600
        _log (LOG_DEBUG, "%s: handling avp's for tunnel %d, call %d\n",
1601
             __FUNCTION__, t->ourtid, c->ourcid);
1601
             __FUNCTION__, t->ourtid, c->ourcid);
1602
    while (len > 0)
1602
    while (len > 0)
1603
    {
1603
    {
Lines 1607-1613 Link Here
1607
        {
1607
        {
1608
            if (AMBIT (avp->length))
1608
            if (AMBIT (avp->length))
1609
            {
1609
            {
1610
                log (LOG_WARN,
1610
                _log (LOG_WARN,
1611
                     "%s:  dont know how to handle mandatory attribute %d.  Closing %s.\n"
1611
                     "%s:  dont know how to handle mandatory attribute %d.  Closing %s.\n"
1612
                     __FUNCTION__, avp->attr,
1612
                     __FUNCTION__, avp->attr,
1613
                     (c != t->self) ? "call" : "tunnel");
1613
                     (c != t->self) ? "call" : "tunnel");
Lines 1620-1626 Link Here
1620
            else
1620
            else
1621
            {
1621
            {
1622
                if (DEBUG)
1622
                if (DEBUG)
1623
                    log (LOG_WARN,
1623
                    _log (LOG_WARN,
1624
                         "%s:  dont know how to handle atribute %d.\n",
1624
                         "%s:  dont know how to handle atribute %d.\n",
1625
                         __FUNCTION__, avp->attr);
1625
                         __FUNCTION__, avp->attr);
1626
                goto next;
1626
                goto next;
Lines 1628-1634 Link Here
1628
        }
1628
        }
1629
        if (ALENGTH (avp->length) > len)
1629
        if (ALENGTH (avp->length) > len)
1630
        {
1630
        {
1631
            log (LOG_WARN,
1631
            _log (LOG_WARN,
1632
                 "%s: AVP received with length > remaining packet length!\n",
1632
                 "%s: AVP received with length > remaining packet length!\n",
1633
                 __FUNCTION__);
1633
                 __FUNCTION__);
1634
            set_error (c, ERROR_LENGTH, "Invalid AVP length");
1634
            set_error (c, ERROR_LENGTH, "Invalid AVP length");
Lines 1637-1643 Link Here
1637
        }
1637
        }
1638
        if (avp->attr && firstavp)
1638
        if (avp->attr && firstavp)
1639
        {
1639
        {
1640
            log (LOG_WARN, "%s: First AVP was not message type.\n",
1640
            _log (LOG_WARN, "%s: First AVP was not message type.\n",
1641
                 __FUNCTION__);
1641
                 __FUNCTION__);
1642
            set_error (c, VENDOR_ERROR, "First AVP must be message type");
1642
            set_error (c, VENDOR_ERROR, "First AVP must be message type");
1643
            c->needclose = -1;
1643
            c->needclose = -1;
Lines 1645-1651 Link Here
1645
        }
1645
        }
1646
        if (ALENGTH (avp->length) < sizeof (struct avp_hdr))
1646
        if (ALENGTH (avp->length) < sizeof (struct avp_hdr))
1647
        {
1647
        {
1648
            log (LOG_WARN, "%s: AVP with too small of size (%d).\n",
1648
            _log (LOG_WARN, "%s: AVP with too small of size (%d).\n",
1649
                 __FUNCTION__, ALENGTH (avp->length));
1649
                 __FUNCTION__, ALENGTH (avp->length));
1650
            set_error (c, ERROR_LENGTH, "AVP too small");
1650
            set_error (c, ERROR_LENGTH, "AVP too small");
1651
            c->needclose = -1;
1651
            c->needclose = -1;
Lines 1653-1659 Link Here
1653
        }
1653
        }
1654
        if (AZBITS (avp->length))
1654
        if (AZBITS (avp->length))
1655
        {
1655
        {
1656
            log (LOG_WARN, "%s: %sAVP has reserved bits set.\n", __FUNCTION__,
1656
            _log (LOG_WARN, "%s: %sAVP has reserved bits set.\n", __FUNCTION__,
1657
                 AMBIT (avp->length) ? "Mandatory " : "");
1657
                 AMBIT (avp->length) ? "Mandatory " : "");
1658
            if (AMBIT (avp->length))
1658
            if (AMBIT (avp->length))
1659
            {
1659
            {
Lines 1666-1672 Link Here
1666
        if (AHBIT (avp->length))
1666
        if (AHBIT (avp->length))
1667
        {
1667
        {
1668
#ifdef DEBUG_HIDDEN
1668
#ifdef DEBUG_HIDDEN
1669
            log (LOG_DEBUG, "%s: Hidden bit set on AVP.\n", __FUNCTION__);
1669
            _log (LOG_DEBUG, "%s: Hidden bit set on AVP.\n", __FUNCTION__);
1670
#endif
1670
#endif
1671
            /* We want to rewrite the AVP as an unhidden AVP
1671
            /* We want to rewrite the AVP as an unhidden AVP
1672
               and then pass it along as normal.  Remeber how
1672
               and then pass it along as normal.  Remeber how
Lines 1675-1681 Link Here
1675
            if (decrypt_avp (data, t))
1675
            if (decrypt_avp (data, t))
1676
            {
1676
            {
1677
                if (debug_avp)
1677
                if (debug_avp)
1678
                    log (LOG_WARN, "%s: Unable to handle hidden %sAVP\n:",
1678
                    _log (LOG_WARN, "%s: Unable to handle hidden %sAVP\n:",
1679
                         __FUNCTION__,
1679
                         __FUNCTION__,
1680
                         (AMBIT (avp->length) ? "mandatory " : ""));
1680
                         (AMBIT (avp->length) ? "mandatory " : ""));
1681
                if (AMBIT (avp->length))
1681
                if (AMBIT (avp->length))
Lines 1700-1706 Link Here
1700
            {
1700
            {
1701
                if (AMBIT (avp->length))
1701
                if (AMBIT (avp->length))
1702
                {
1702
                {
1703
                    log (LOG_WARN,
1703
                    _log (LOG_WARN,
1704
                         "%s: Bad exit status handling attribute %d (%s) on mandatory packet.\n",
1704
                         "%s: Bad exit status handling attribute %d (%s) on mandatory packet.\n",
1705
                         __FUNCTION__, avp->attr,
1705
                         __FUNCTION__, avp->attr,
1706
                         avps[avp->attr].description);
1706
                         avps[avp->attr].description);
Lines 1710-1716 Link Here
1710
                else
1710
                else
1711
                {
1711
                {
1712
                    if (DEBUG)
1712
                    if (DEBUG)
1713
                        log (LOG_DEBUG,
1713
                        _log (LOG_DEBUG,
1714
                             "%s: Bad exit status handling attribute %d (%s).\n",
1714
                             "%s: Bad exit status handling attribute %d (%s).\n",
1715
                             __FUNCTION__, avp->attr,
1715
                             __FUNCTION__, avp->attr,
1716
                             avps[avp->attr].description);
1716
                             avps[avp->attr].description);
Lines 1721-1727 Link Here
1721
        {
1721
        {
1722
            if (AMBIT (avp->length))
1722
            if (AMBIT (avp->length))
1723
            {
1723
            {
1724
                log (LOG_WARN,
1724
                _log (LOG_WARN,
1725
                     "%s:  No handler for mandatory attribute %d (%s).  Closing %s.\n",
1725
                     "%s:  No handler for mandatory attribute %d (%s).  Closing %s.\n",
1726
                     __FUNCTION__, avp->attr, avps[avp->attr].description,
1726
                     __FUNCTION__, avp->attr, avps[avp->attr].description,
1727
                     (c != t->self) ? "call" : "tunnel");
1727
                     (c != t->self) ? "call" : "tunnel");
Lines 1732-1738 Link Here
1732
            else
1732
            else
1733
            {
1733
            {
1734
                if (DEBUG)
1734
                if (DEBUG)
1735
                    log (LOG_WARN, "%s:  no handler for atribute %d (%s).\n",
1735
                    _log (LOG_WARN, "%s:  no handler for atribute %d (%s).\n",
1736
                         __FUNCTION__, avp->attr,
1736
                         __FUNCTION__, avp->attr,
1737
                         avps[avp->attr].description);
1737
                         avps[avp->attr].description);
1738
            }
1738
            }
Lines 1754-1760 Link Here
1754
    }
1754
    }
1755
    if (len != 0)
1755
    if (len != 0)
1756
    {
1756
    {
1757
        log (LOG_WARN, "%s: negative overall packet length\n", __FUNCTION__);
1757
        _log (LOG_WARN, "%s: negative overall packet length\n", __FUNCTION__);
1758
        return -EINVAL;
1758
        return -EINVAL;
1759
    }
1759
    }
1760
    return 0;
1760
    return 0;
(-)l2tpd-0.69/call.c (-20 / +20 lines)
Lines 136-146 Link Here
136
                return 0;
136
                return 0;
137
            }
137
            }
138
            errors++;
138
            errors++;
139
            log (LOG_DEBUG, "%s: Error %d (%s)\n", __FUNCTION__, errno,
139
            _log (LOG_DEBUG, "%s: Error %d (%s)\n", __FUNCTION__, errno,
140
                 strerror (errno));
140
                 strerror (errno));
141
            if (errors > 10)
141
            if (errors > 10)
142
            {
142
            {
143
                log (LOG_DEBUG,
143
                _log (LOG_DEBUG,
144
                     "%s: Too many errors.  Declaring call dead.\n",
144
                     "%s: Too many errors.  Declaring call dead.\n",
145
                     __FUNCTION__);
145
                     __FUNCTION__);
146
                return -errno;
146
                return -errno;
Lines 152-158 Link Here
152
        case PPP_FLAG:
152
        case PPP_FLAG:
153
            if (escape)
153
            if (escape)
154
            {
154
            {
155
                log (LOG_DEBUG, "%s: got an escaped PPP_FLAG\n",
155
                _log (LOG_DEBUG, "%s: got an escaped PPP_FLAG\n",
156
                     __FUNCTION__);
156
                     __FUNCTION__);
157
                return -EINVAL;
157
                return -EINVAL;
158
            }
158
            }
Lines 188-199 Link Here
188
                buf->len++;
188
                buf->len++;
189
                break;
189
                break;
190
            };
190
            };
191
            log (LOG_WARN, "%s: read overrun\n", __FUNCTION__);
191
            _log (LOG_WARN, "%s: read overrun\n", __FUNCTION__);
192
            return -EINVAL;
192
            return -EINVAL;
193
        }
193
        }
194
    }
194
    }
195
    /* I should never get here */
195
    /* I should never get here */
196
    log (LOG_WARN, "%s: You should not see this message.  If you do, please
196
    _log (LOG_WARN, "%s: You should not see this message.  If you do, please\n\
197
		       enter a bug report at http://sourceforge.net/projects/l2tpd", __FUNCTION__);
197
		       enter a bug report at http://sourceforge.net/projects/l2tpd", __FUNCTION__);
198
    return -EINVAL;
198
    return -EINVAL;
199
}
199
}
Lines 205-211 Link Here
205
    struct call *tmp, *tmp2;
205
    struct call *tmp, *tmp2;
206
    if (!c || !c->container)
206
    if (!c || !c->container)
207
    {
207
    {
208
        log (LOG_DEBUG, "%s: called on null call or containerless call\n",
208
        _log (LOG_DEBUG, "%s: called on null call or containerless call\n",
209
             __FUNCTION__);
209
             __FUNCTION__);
210
        return;
210
        return;
211
    }
211
    }
Lines 229-235 Link Here
229
                || ((struct tunnel *) se->data == c->container))
229
                || ((struct tunnel *) se->data == c->container))
230
            {
230
            {
231
#ifdef DEBUG_CLOSE
231
#ifdef DEBUG_CLOSE
232
                log (LOG_DEBUG, "%s: Descheduling event\n", __FUNCTION__);
232
                _log (LOG_DEBUG, "%s: Descheduling event\n", __FUNCTION__);
233
#endif
233
#endif
234
                if (ose)
234
                if (ose)
235
                {
235
                {
Lines 260-266 Link Here
260
            /* Really close this tunnel, as our
260
            /* Really close this tunnel, as our
261
               StopCCN has been ack'd */
261
               StopCCN has been ack'd */
262
#ifdef DEBUG_CLOSE
262
#ifdef DEBUG_CLOSE
263
            log (LOG_DEBUG, "%s: Actually closing tunnel %d\n", __FUNCTION__,
263
            _log (LOG_DEBUG, "%s: Actually closing tunnel %d\n", __FUNCTION__,
264
                 c->container->ourtid);
264
                 c->container->ourtid);
265
#endif
265
#endif
266
#ifdef USE_KERNEL
266
#ifdef USE_KERNEL
Lines 296-302 Link Here
296
        if (packet_dump)
296
        if (packet_dump)
297
            do_packet_dump (buf);
297
            do_packet_dump (buf);
298
#ifdef DEBUG_CLOSE
298
#ifdef DEBUG_CLOSE
299
        log (LOG_DEBUG, "%s: enqueing close message for tunnel\n",
299
        _log (LOG_DEBUG, "%s: enqueing close message for tunnel\n",
300
             __FUNCTION__);
300
             __FUNCTION__);
301
#endif
301
#endif
302
        control_xmit (buf);
302
        control_xmit (buf);
Lines 313-319 Link Here
313
            call_close (tmp);
313
            call_close (tmp);
314
            tmp = tmp2;
314
            tmp = tmp2;
315
        }
315
        }
316
        log (LOG_LOG,
316
        _log (LOG_LOG,
317
             "%s : Connection %d closed to %s, port %d (%s)\n", __FUNCTION__,
317
             "%s : Connection %d closed to %s, port %d (%s)\n", __FUNCTION__,
318
             c->container->tid,
318
             c->container->tid,
319
             IPADDY (c->container->peer.sin_addr),
319
             IPADDY (c->container->peer.sin_addr),
Lines 333-339 Link Here
333
        if (c->closing)
333
        if (c->closing)
334
        {
334
        {
335
#ifdef DEBUG_CLOSE
335
#ifdef DEBUG_CLOSE
336
            log (LOG_DEBUG, "%s: Actually closing call %d\n", __FUNCTION__,
336
            _log (LOG_DEBUG, "%s: Actually closing call %d\n", __FUNCTION__,
337
                 c->ourcid);
337
                 c->ourcid);
338
#endif
338
#endif
339
            destroy_call (c);
339
            destroy_call (c);
Lines 373-383 Link Here
373
        if (packet_dump)
373
        if (packet_dump)
374
            do_packet_dump (buf);
374
            do_packet_dump (buf);
375
#ifdef DEBUG_CLOSE
375
#ifdef DEBUG_CLOSE
376
        log (LOG_DEBUG, "%s: enqueuing close message for call %d\n",
376
        _log (LOG_DEBUG, "%s: enqueuing close message for call %d\n",
377
             __FUNCTION__, c->ourcid);
377
             __FUNCTION__, c->ourcid);
378
#endif
378
#endif
379
        control_xmit (buf);
379
        control_xmit (buf);
380
        log (LOG_LOG, "%s: Call %d to %s disconnected\n", __FUNCTION__,
380
        _log (LOG_LOG, "%s: Call %d to %s disconnected\n", __FUNCTION__,
381
             c->ourcid, IPADDY (c->container->peer.sin_addr));
381
             c->ourcid, IPADDY (c->container->peer.sin_addr));
382
    }
382
    }
383
    /*
383
    /*
Lines 461-467 Link Here
461
            c->lac->active)
461
            c->lac->active)
462
        {
462
        {
463
#ifdef DEBUG_MAGIC
463
#ifdef DEBUG_MAGIC
464
            log (LOG_LOG, "%s: Will redial in %d seconds\n", __FUNCTION__,
464
            _log (LOG_LOG, "%s: Will redial in %d seconds\n", __FUNCTION__,
465
                 c->lac->rtimeout);
465
                 c->lac->rtimeout);
466
#endif
466
#endif
467
            tv.tv_sec = c->lac->rtimeout;
467
            tv.tv_sec = c->lac->rtimeout;
Lines 517-523 Link Here
517
            temp = (int *)entropy_buf;
517
            temp = (int *)entropy_buf;
518
            tmp->ourcid = *temp & 0xFFFF;
518
            tmp->ourcid = *temp & 0xFFFF;
519
#ifdef DEBUG_ENTROPY
519
#ifdef DEBUG_ENTROPY
520
            log(LOG_DEBUG, "ourcid = %u, entropy_buf = %hx\n", tmp->ourcid, *temp);
520
            _log(LOG_DEBUG, "ourcid = %u, entropy_buf = %hx\n", tmp->ourcid, *temp);
521
#endif
521
#endif
522
        }
522
        }
523
#else
523
#else
Lines 606-612 Link Here
606
                            return sc;
606
                            return sc;
607
                        sc = sc->next;
607
                        sc = sc->next;
608
                    }
608
                    }
609
                    log (LOG_DEBUG, "%s: can't find call %d in tunnel %d\n",
609
                    _log (LOG_DEBUG, "%s: can't find call %d in tunnel %d\n",
610
                         __FUNCTION__, call, tunnel);
610
                         __FUNCTION__, call, tunnel);
611
                    return NULL;
611
                    return NULL;
612
                }
612
                }
Lines 617-623 Link Here
617
            }
617
            }
618
            st = st->next;
618
            st = st->next;
619
        }
619
        }
620
        log (LOG_DEBUG, "%s:can't find tunnel %d\n", __FUNCTION__, tunnel);
620
        _log (LOG_DEBUG, "%s:can't find tunnel %d\n", __FUNCTION__, tunnel);
621
        return NULL;
621
        return NULL;
622
    }
622
    }
623
    else
623
    else
Lines 630-636 Link Here
630
630
631
        if (call)
631
        if (call)
632
        {
632
        {
633
            log (LOG_WARN,
633
            _log (LOG_WARN,
634
                 "%s: call ID specified, but no tunnel ID specified.  tossing.\n",
634
                 "%s: call ID specified, but no tunnel ID specified.  tossing.\n",
635
                 __FUNCTION__);
635
                 __FUNCTION__);
636
            return NULL;
636
            return NULL;
Lines 641-653 Link Here
641
         */
641
         */
642
        if (debug_tunnel)
642
        if (debug_tunnel)
643
        {
643
        {
644
            log (LOG_DEBUG,
644
            _log (LOG_DEBUG,
645
                 "%s: allocating new tunnel for host %s, port %d.\n",
645
                 "%s: allocating new tunnel for host %s, port %d.\n",
646
                 __FUNCTION__, IPADDY (addr), ntohs (port));
646
                 __FUNCTION__, IPADDY (addr), ntohs (port));
647
        }
647
        }
648
        if (!(st = new_tunnel ()))
648
        if (!(st = new_tunnel ()))
649
        {
649
        {
650
            log (LOG_WARN,
650
            _log (LOG_WARN,
651
                 "%s: unable to allocate new tunnel for host %s, port %d.\n",
651
                 "%s: unable to allocate new tunnel for host %s, port %d.\n",
652
                 __FUNCTION__, IPADDY (addr), ntohs (port));
652
                 __FUNCTION__, IPADDY (addr), ntohs (port));
653
            return NULL;
653
            return NULL;
(-)l2tpd-0.69/control.c (-106 / +106 lines)
Lines 136-149 Link Here
136
    if (packet_dump)
136
    if (packet_dump)
137
        do_packet_dump (buf);
137
        do_packet_dump (buf);
138
#ifdef DEBUG_HELLO
138
#ifdef DEBUG_HELLO
139
    log (LOG_DEBUG, "%s: sending Hello on %d\n", __FUNCTION__, t->ourtid);
139
    _log (LOG_DEBUG, "%s: sending Hello on %d\n", __FUNCTION__, t->ourtid);
140
#endif
140
#endif
141
    control_xmit (buf);
141
    control_xmit (buf);
142
    /*
142
    /*
143
     * Schedule another Hello in a little bit.
143
     * Schedule another Hello in a little bit.
144
     */
144
     */
145
#ifdef DEBUG_HELLO
145
#ifdef DEBUG_HELLO
146
    log (LOG_DEBUG, "%s: scheduling another Hello on %d\n", __FUNCTION__,
146
    _log (LOG_DEBUG, "%s: scheduling another Hello on %d\n", __FUNCTION__,
147
         t->ourtid);
147
         t->ourtid);
148
#endif
148
#endif
149
    t->hello = schedule (tv, hello, (void *) t);
149
    t->hello = schedule (tv, hello, (void *) t);
Lines 155-161 Link Here
155
    add_control_hdr (t, c, buf);
155
    add_control_hdr (t, c, buf);
156
    t->control_seq_num--;
156
    t->control_seq_num--;
157
#ifdef DEBUG_ZLB
157
#ifdef DEBUG_ZLB
158
    log (LOG_DEBUG, "%s: sending control ZLB on tunnel %d\n", __FUNCTION__,
158
    _log (LOG_DEBUG, "%s: sending control ZLB on tunnel %d\n", __FUNCTION__,
159
         t->tid);
159
         t->tid);
160
#endif
160
#endif
161
    udp_xmit (buf);
161
    udp_xmit (buf);
Lines 185-196 Link Here
185
    char dummy_buf[128] = "/var/l2tp/"; /* jz: needed to read /etc/ppp/var.options - just kick it if you dont like */
185
    char dummy_buf[128] = "/var/l2tp/"; /* jz: needed to read /etc/ppp/var.options - just kick it if you dont like */
186
    if (c->msgtype < 0)
186
    if (c->msgtype < 0)
187
    {
187
    {
188
        log (LOG_DEBUG, "%s: Whoa...  non-ZLB with no message type!\n",
188
        _log (LOG_DEBUG, "%s: Whoa...  non-ZLB with no message type!\n",
189
             __FUNCTION__);
189
             __FUNCTION__);
190
        return -EINVAL;
190
        return -EINVAL;
191
    }
191
    }
192
    if (debug_state)
192
    if (debug_state)
193
        log (LOG_DEBUG,
193
        _log (LOG_DEBUG,
194
             "%s: message type is %s(%d).  Tunnel is %d, call is %d.\n",
194
             "%s: message type is %s(%d).  Tunnel is %d, call is %d.\n",
195
             __FUNCTION__, msgtypes[c->msgtype], c->msgtype, t->tid, c->cid);
195
             __FUNCTION__, msgtypes[c->msgtype], c->msgtype, t->tid, c->cid);
196
    switch (c->msgtype)
196
    switch (c->msgtype)
Lines 245-251 Link Here
245
            if (packet_dump)
245
            if (packet_dump)
246
                do_packet_dump (buf);
246
                do_packet_dump (buf);
247
            if (debug_state)
247
            if (debug_state)
248
                log (LOG_DEBUG, "%s: control_finish: sending SCCRQ\n",
248
                _log (LOG_DEBUG, "%s: control_finish: sending SCCRQ\n",
249
                     __FUNCTION__);
249
                     __FUNCTION__);
250
            control_xmit (buf);
250
            control_xmit (buf);
251
        }
251
        }
Lines 287-293 Link Here
287
                if (packet_dump)
287
                if (packet_dump)
288
                    do_packet_dump (buf);
288
                    do_packet_dump (buf);
289
                if (debug_state)
289
                if (debug_state)
290
                    log (LOG_DEBUG, "%s: sending ICRQ\n", __FUNCTION__);
290
                    _log (LOG_DEBUG, "%s: sending ICRQ\n", __FUNCTION__);
291
                control_xmit (buf);
291
                control_xmit (buf);
292
            }
292
            }
293
            else
293
            else
Lines 340-346 Link Here
340
        if (t->tid <= 0)
340
        if (t->tid <= 0)
341
        {
341
        {
342
            if (DEBUG)
342
            if (DEBUG)
343
                log (LOG_DEBUG,
343
                _log (LOG_DEBUG,
344
                     "%s: Peer did not specify assigned tunnel ID.  Closing.\n",
344
                     "%s: Peer did not specify assigned tunnel ID.  Closing.\n",
345
                     __FUNCTION__);
345
                     __FUNCTION__);
346
            set_error (c, VENDOR_ERROR, "Specify your assigned tunnel ID");
346
            set_error (c, VENDOR_ERROR, "Specify your assigned tunnel ID");
Lines 350-356 Link Here
350
        if (!(t->lns = get_lns (t)))
350
        if (!(t->lns = get_lns (t)))
351
        {
351
        {
352
            if (DEBUG)
352
            if (DEBUG)
353
                log (LOG_DEBUG,
353
                _log (LOG_DEBUG,
354
                     "%s: Denied connection to unauthorized peer %s\n",
354
                     "%s: Denied connection to unauthorized peer %s\n",
355
                     __FUNCTION__, IPADDY (t->peer.sin_addr));
355
                     __FUNCTION__, IPADDY (t->peer.sin_addr));
356
            set_error (c, VENDOR_ERROR, "No Authorization");
356
            set_error (c, VENDOR_ERROR, "No Authorization");
Lines 362-368 Link Here
362
        if (t->fc < 0)
362
        if (t->fc < 0)
363
        {
363
        {
364
            if (DEBUG)
364
            if (DEBUG)
365
                log (LOG_DEBUG,
365
                _log (LOG_DEBUG,
366
                     "%s: Peer did not specify framing capability.  Closing.\n",
366
                     "%s: Peer did not specify framing capability.  Closing.\n",
367
                     __FUNCTION__);
367
                     __FUNCTION__);
368
            set_error (c, VENDOR_ERROR, "Specify framing capability");
368
            set_error (c, VENDOR_ERROR, "Specify framing capability");
Lines 375-381 Link Here
375
         * We shouldn't be requiring a bearer capabilities avp to be present in 
375
         * We shouldn't be requiring a bearer capabilities avp to be present in 
376
         * SCCRQ and SCCRP as they aren't required
376
         * SCCRQ and SCCRP as they aren't required
377
         if (t->bc < 0 ) {
377
         if (t->bc < 0 ) {
378
         if (DEBUG) log(LOG_DEBUG,
378
         if (DEBUG) _log(LOG_DEBUG,
379
         "%s: Peer did not specify bearer capability.  Closing.\n",__FUNCTION__);
379
         "%s: Peer did not specify bearer capability.  Closing.\n",__FUNCTION__);
380
         set_error(c, VENDOR_ERROR, "Specify bearer capability");
380
         set_error(c, VENDOR_ERROR, "Specify bearer capability");
381
         c->needclose = -1;
381
         c->needclose = -1;
Lines 384-390 Link Here
384
        if (!strlen (t->hostname))
384
        if (!strlen (t->hostname))
385
        {
385
        {
386
            if (DEBUG)
386
            if (DEBUG)
387
                log (LOG_DEBUG,
387
                _log (LOG_DEBUG,
388
                     "%s: Peer did not specify hostname.  Closing.\n",
388
                     "%s: Peer did not specify hostname.  Closing.\n",
389
                     __FUNCTION__);
389
                     __FUNCTION__);
390
            set_error (c, VENDOR_ERROR, "Specify your hostname");
390
            set_error (c, VENDOR_ERROR, "Specify your hostname");
Lines 404-410 Link Here
404
                 * But it is legitimate for two different remote systems
404
                 * But it is legitimate for two different remote systems
405
                 * to use the same tid
405
                 * to use the same tid
406
                 */
406
                 */
407
                log (LOG_DEBUG,
407
                _log (LOG_DEBUG,
408
                     "%s: Peer requested tunnel %d twice, ignoring second one.\n",
408
                     "%s: Peer requested tunnel %d twice, ignoring second one.\n",
409
                     __FUNCTION__, t->tid);
409
                     __FUNCTION__, t->tid);
410
                c->needclose = 0;
410
                c->needclose = 0;
Lines 441-447 Link Here
441
            t->chal_them.challenge = malloc(MD_SIG_SIZE);
441
            t->chal_them.challenge = malloc(MD_SIG_SIZE);
442
            if (!(t->chal_them.challenge))
442
            if (!(t->chal_them.challenge))
443
            {
443
            {
444
                log (LOG_WARN, "%s: malloc failed\n", __FUNCTION__);
444
                _log (LOG_WARN, "%s: malloc failed\n", __FUNCTION__);
445
                set_error (c, VENDOR_ERROR, "malloc failed");
445
                set_error (c, VENDOR_ERROR, "malloc failed");
446
                toss (buf);
446
                toss (buf);
447
                return -EINVAL;
447
                return -EINVAL;
Lines 451-457 Link Here
451
            if (handle_challenge (t, &t->chal_them))
451
            if (handle_challenge (t, &t->chal_them))
452
            {
452
            {
453
                /* We already know what to expect back */
453
                /* We already know what to expect back */
454
                log (LOG_WARN, "%s: No secret for '%s'\n", __FUNCTION__,
454
                _log (LOG_WARN, "%s: No secret for '%s'\n", __FUNCTION__,
455
                     t->hostname);
455
                     t->hostname);
456
                set_error (c, VENDOR_ERROR, "No secret on our side");
456
                set_error (c, VENDOR_ERROR, "No secret on our side");
457
                toss (buf);
457
                toss (buf);
Lines 464-470 Link Here
464
            do_packet_dump (buf);
464
            do_packet_dump (buf);
465
        c->cnu = 0;
465
        c->cnu = 0;
466
        if (debug_state)
466
        if (debug_state)
467
            log (LOG_DEBUG, "%s: sending SCCRP\n", __FUNCTION__);
467
            _log (LOG_DEBUG, "%s: sending SCCRP\n", __FUNCTION__);
468
        control_xmit (buf);
468
        control_xmit (buf);
469
        break;
469
        break;
470
    case SCCRP:
470
    case SCCRP:
Lines 475-481 Link Here
475
        if (t->fc < 0)
475
        if (t->fc < 0)
476
        {
476
        {
477
            if (DEBUG)
477
            if (DEBUG)
478
                log (LOG_DEBUG,
478
                _log (LOG_DEBUG,
479
                     "%s: Peer did not specify framing capability.  Closing.\n",
479
                     "%s: Peer did not specify framing capability.  Closing.\n",
480
                     __FUNCTION__);
480
                     __FUNCTION__);
481
            set_error (c, VENDOR_ERROR, "Specify framing capability");
481
            set_error (c, VENDOR_ERROR, "Specify framing capability");
Lines 488-494 Link Here
488
         * We shouldn't be requiring a bearer capabilities avp to be present in 
488
         * We shouldn't be requiring a bearer capabilities avp to be present in 
489
         * SCCRQ and SCCRP as they aren't required
489
         * SCCRQ and SCCRP as they aren't required
490
         if (t->bc < 0 ) {
490
         if (t->bc < 0 ) {
491
         if (DEBUG) log(LOG_DEBUG,
491
         if (DEBUG) _log(LOG_DEBUG,
492
         "%s: Peer did not specify bearer capability.  Closing.\n",__FUNCTION__);
492
         "%s: Peer did not specify bearer capability.  Closing.\n",__FUNCTION__);
493
         set_error(c, VENDOR_ERROR, "Specify bearer capability");
493
         set_error(c, VENDOR_ERROR, "Specify bearer capability");
494
         c->needclose = -1;
494
         c->needclose = -1;
Lines 497-503 Link Here
497
        if (!strlen (t->hostname))
497
        if (!strlen (t->hostname))
498
        {
498
        {
499
            if (DEBUG)
499
            if (DEBUG)
500
                log (LOG_DEBUG,
500
                _log (LOG_DEBUG,
501
                     "%s: Peer did not specify hostname.  Closing.\n",
501
                     "%s: Peer did not specify hostname.  Closing.\n",
502
                     __FUNCTION__);
502
                     __FUNCTION__);
503
            set_error (c, VENDOR_ERROR, "Specify your hostname");
503
            set_error (c, VENDOR_ERROR, "Specify your hostname");
Lines 507-513 Link Here
507
        if (t->tid <= 0)
507
        if (t->tid <= 0)
508
        {
508
        {
509
            if (DEBUG)
509
            if (DEBUG)
510
                log (LOG_DEBUG,
510
                _log (LOG_DEBUG,
511
                     "%s: Peer did not specify assigned tunnel ID.  Closing.\n",
511
                     "%s: Peer did not specify assigned tunnel ID.  Closing.\n",
512
                     __FUNCTION__);
512
                     __FUNCTION__);
513
            set_error (c, VENDOR_ERROR, "Specify your assigned tunnel ID");
513
            set_error (c, VENDOR_ERROR, "Specify your assigned tunnel ID");
Lines 520-526 Link Here
520
            if (handle_challenge (t, &t->chal_them))
520
            if (handle_challenge (t, &t->chal_them))
521
            {
521
            {
522
                set_error (c, VENDOR_ERROR, "No secret key on our side");
522
                set_error (c, VENDOR_ERROR, "No secret key on our side");
523
                log (LOG_WARN, "%s: No secret key for authenticating '%s'\n",
523
                _log (LOG_WARN, "%s: No secret key for authenticating '%s'\n",
524
                     __FUNCTION__, t->hostname);
524
                     __FUNCTION__, t->hostname);
525
                c->needclose = -1;
525
                c->needclose = -1;
526
                return -EINVAL;
526
                return -EINVAL;
Lines 530-536 Link Here
530
            {
530
            {
531
                set_error (c, VENDOR_ERROR,
531
                set_error (c, VENDOR_ERROR,
532
                           "Invalid challenge authentication");
532
                           "Invalid challenge authentication");
533
                log (LOG_DEBUG, "%s: Invalid authentication for host '%s'\n",
533
                _log (LOG_DEBUG, "%s: Invalid authentication for host '%s'\n",
534
                     __FUNCTION__, t->hostname);
534
                     __FUNCTION__, t->hostname);
535
                c->needclose = -1;
535
                c->needclose = -1;
536
                return -EINVAL;
536
                return -EINVAL;
Lines 541-547 Link Here
541
            t->chal_us.ss = SCCCN;
541
            t->chal_us.ss = SCCCN;
542
            if (handle_challenge (t, &t->chal_us))
542
            if (handle_challenge (t, &t->chal_us))
543
            {
543
            {
544
                log (LOG_WARN, "%s: No secret for authenticating to '%s'\n",
544
                _log (LOG_WARN, "%s: No secret for authenticating to '%s'\n",
545
                     __FUNCTION__, t->hostname);
545
                     __FUNCTION__, t->hostname);
546
                set_error (c, VENDOR_ERROR, "No secret key on our end");
546
                set_error (c, VENDOR_ERROR, "No secret key on our end");
547
                c->needclose = -1;
547
                c->needclose = -1;
Lines 573-589 Link Here
573
            do_packet_dump (buf);
573
            do_packet_dump (buf);
574
        c->cnu = 0;
574
        c->cnu = 0;
575
        if (debug_state)
575
        if (debug_state)
576
            log (LOG_DEBUG, "%s: sending SCCCN\n", __FUNCTION__);
576
            _log (LOG_DEBUG, "%s: sending SCCCN\n", __FUNCTION__);
577
        control_xmit (buf);
577
        control_xmit (buf);
578
        /* Schedule a HELLO */
578
        /* Schedule a HELLO */
579
        tv.tv_sec = HELLO_DELAY;
579
        tv.tv_sec = HELLO_DELAY;
580
        tv.tv_usec = 0;
580
        tv.tv_usec = 0;
581
#ifdef DEBUG_HELLO
581
#ifdef DEBUG_HELLO
582
        log (LOG_DEBUG, "%s: scheduling initial HELLO on %d\n", __FUNCTION__,
582
        _log (LOG_DEBUG, "%s: scheduling initial HELLO on %d\n", __FUNCTION__,
583
             t->ourtid);
583
             t->ourtid);
584
#endif
584
#endif
585
        t->hello = schedule (tv, hello, (void *) t);
585
        t->hello = schedule (tv, hello, (void *) t);
586
        log (LOG_LOG,
586
        _log (LOG_LOG,
587
             "%s: Connection established to %s, %d.  Local: %d, Remote: %d.\n",
587
             "%s: Connection established to %s, %d.  Local: %d, Remote: %d.\n",
588
             __FUNCTION__, IPADDY (t->peer.sin_addr),
588
             __FUNCTION__, IPADDY (t->peer.sin_addr),
589
             ntohs (t->peer.sin_port), t->ourtid, t->tid);
589
             ntohs (t->peer.sin_port), t->ourtid, t->tid);
Lines 602-608 Link Here
602
            {
602
            {
603
                set_error (c, VENDOR_ERROR,
603
                set_error (c, VENDOR_ERROR,
604
                           "Invalid challenge authentication");
604
                           "Invalid challenge authentication");
605
                log (LOG_DEBUG, "%s: Invalid authentication for host '%s'\n",
605
                _log (LOG_DEBUG, "%s: Invalid authentication for host '%s'\n",
606
                     __FUNCTION__, t->hostname);
606
                     __FUNCTION__, t->hostname);
607
                c->needclose = -1;
607
                c->needclose = -1;
608
                return -EINVAL;
608
                return -EINVAL;
Lines 619-625 Link Here
619
        }
619
        }
620
#endif
620
#endif
621
        t->state = SCCCN;
621
        t->state = SCCCN;
622
        log (LOG_LOG,
622
        _log (LOG_LOG,
623
             "%s: Connection established to %s, %d.  Local: %d, Remote: %d.  LNS session is '%s'\n",
623
             "%s: Connection established to %s, %d.  Local: %d, Remote: %d.  LNS session is '%s'\n",
624
             __FUNCTION__, IPADDY (t->peer.sin_addr),
624
             __FUNCTION__, IPADDY (t->peer.sin_addr),
625
             ntohs (t->peer.sin_port), t->ourtid, t->tid, t->lns->entname);
625
             ntohs (t->peer.sin_port), t->ourtid, t->tid, t->lns->entname);
Lines 627-633 Link Here
627
        tv.tv_sec = HELLO_DELAY;
627
        tv.tv_sec = HELLO_DELAY;
628
        tv.tv_usec = 0;
628
        tv.tv_usec = 0;
629
#ifdef DEBUG_HELLO
629
#ifdef DEBUG_HELLO
630
        log (LOG_DEBUG, "%s: scheduling initial HELLO on %d\n", __FUNCTION__,
630
        _log (LOG_DEBUG, "%s: scheduling initial HELLO on %d\n", __FUNCTION__,
631
             t->ourtid);
631
             t->ourtid);
632
#endif
632
#endif
633
        t->hello = schedule (tv, hello, (void *) t);
633
        t->hello = schedule (tv, hello, (void *) t);
Lines 636-642 Link Here
636
        if (t->qtid < 0)
636
        if (t->qtid < 0)
637
        {
637
        {
638
            if (DEBUG)
638
            if (DEBUG)
639
                log (LOG_DEBUG,
639
                _log (LOG_DEBUG,
640
                     "%s: Peer tried to disconnect without specifying tunnel ID\n",
640
                     "%s: Peer tried to disconnect without specifying tunnel ID\n",
641
                     __FUNCTION__);
641
                     __FUNCTION__);
642
            return -EINVAL;
642
            return -EINVAL;
Lines 644-650 Link Here
644
        if ((t->qtid != t->tid) && (t->tid > 0))
644
        if ((t->qtid != t->tid) && (t->tid > 0))
645
        {
645
        {
646
            if (DEBUG)
646
            if (DEBUG)
647
                log (LOG_DEBUG,
647
                _log (LOG_DEBUG,
648
                     "%s: Peer tried to disconnect with invalid TID (%d != %d)\n",
648
                     "%s: Peer tried to disconnect with invalid TID (%d != %d)\n",
649
                     __FUNCTION__, t->qtid, t->tid);
649
                     __FUNCTION__, t->qtid, t->tid);
650
            return -EINVAL;
650
            return -EINVAL;
Lines 655-666 Link Here
655
        if (t->self->result < 0)
655
        if (t->self->result < 0)
656
        {
656
        {
657
            if (DEBUG)
657
            if (DEBUG)
658
                log (LOG_DEBUG,
658
                _log (LOG_DEBUG,
659
                     "%s: Peer tried to disconnect without specifying result code.\n",
659
                     "%s: Peer tried to disconnect without specifying result code.\n",
660
                     __FUNCTION__);
660
                     __FUNCTION__);
661
            return -EINVAL;
661
            return -EINVAL;
662
        }
662
        }
663
        log (LOG_LOG,
663
        _log (LOG_LOG,
664
             "%s: Connection closed to %s, port %d (%s), Local: %d, Remote: %d\n",
664
             "%s: Connection closed to %s, port %d (%s), Local: %d, Remote: %d\n",
665
             __FUNCTION__, IPADDY (t->peer.sin_addr),
665
             __FUNCTION__, IPADDY (t->peer.sin_addr),
666
             ntohs (t->peer.sin_port), t->self->errormsg, t->ourtid, t->tid);
666
             ntohs (t->peer.sin_port), t->self->errormsg, t->ourtid, t->tid);
Lines 681-687 Link Here
681
        if (p->cid < 0)
681
        if (p->cid < 0)
682
        {
682
        {
683
            if (DEBUG)
683
            if (DEBUG)
684
                log (LOG_DEBUG,
684
                _log (LOG_DEBUG,
685
                     "%s: Peer tried to initiate call without call ID\n",
685
                     "%s: Peer tried to initiate call without call ID\n",
686
                     __FUNCTION__);
686
                     __FUNCTION__);
687
            /* Here it doesn't make sense to use the needclose flag because 
687
            /* Here it doesn't make sense to use the needclose flag because 
Lines 696-702 Link Here
696
            {
696
            {
697
                /* This can happen if we get a duplicate
697
                /* This can happen if we get a duplicate
698
                   ICRQ or if they don't get our ack packet */
698
                   ICRQ or if they don't get our ack packet */
699
                log (LOG_DEBUG,
699
                _log (LOG_DEBUG,
700
                     "%s: Peer requested call %d twice, ignoring second one.\n",
700
                     "%s: Peer requested call %d twice, ignoring second one.\n",
701
                     __FUNCTION__, p->cid);
701
                     __FUNCTION__, p->cid);
702
                p->needclose = 0;
702
                p->needclose = 0;
Lines 710-718 Link Here
710
         * number avp is included in the ICRQ at all which its required to be.
710
         * number avp is included in the ICRQ at all which its required to be.
711
         * Since the serial number is only used for human debugging aid, this
711
         * Since the serial number is only used for human debugging aid, this
712
         * isn't a big deal, but it would be nice to have *some* sort of check
712
         * isn't a big deal, but it would be nice to have *some* sort of check
713
         * for it and perhaps just log it and go on.  */
713
         * for it and perhaps just _log it and go on.  */
714
/*    JLM	if (p->serno<1) {
714
/*    JLM	if (p->serno<1) {
715
			if (DEBUG) log(LOG_DEBUG,
715
			if (DEBUG) _log(LOG_DEBUG,
716
			"%s: Peer did not specify serial number when initiating call\n", __FUNCTION__);
716
			"%s: Peer did not specify serial number when initiating call\n", __FUNCTION__);
717
			call_close(p);
717
			call_close(p);
718
			return -EINVAL;
718
			return -EINVAL;
Lines 724-730 Link Here
724
        {
724
        {
725
            set_error (p, ERROR_NORES, "No available IP address");
725
            set_error (p, ERROR_NORES, "No available IP address");
726
            call_close (p);
726
            call_close (p);
727
            log (LOG_DEBUG, "%s: Out of IP addresses on tunnel %d!\n",
727
            _log (LOG_DEBUG, "%s: Out of IP addresses on tunnel %d!\n",
728
                 __FUNCTION__, t->tid);
728
                 __FUNCTION__, t->tid);
729
            return -EINVAL;
729
            return -EINVAL;
730
        }
730
        }
Lines 756-769 Link Here
756
            do_packet_dump (buf);
756
            do_packet_dump (buf);
757
        p->cnu = 0;
757
        p->cnu = 0;
758
        if (debug_state)
758
        if (debug_state)
759
            log (LOG_DEBUG, "%s: Sending ICRP\n", __FUNCTION__);
759
            _log (LOG_DEBUG, "%s: Sending ICRP\n", __FUNCTION__);
760
        control_xmit (buf);
760
        control_xmit (buf);
761
        break;
761
        break;
762
    case ICRP:
762
    case ICRP:
763
        if (c->cid < 0)
763
        if (c->cid < 0)
764
        {
764
        {
765
            if (DEBUG)
765
            if (DEBUG)
766
                log (LOG_DEBUG,
766
                _log (LOG_DEBUG,
767
                     "%s: Peer tried to negotiate ICRP without specifying call ID\n",
767
                     "%s: Peer tried to negotiate ICRP without specifying call ID\n",
768
                     __FUNCTION__);
768
                     __FUNCTION__);
769
            c->needclose = -1;
769
            c->needclose = -1;
Lines 811-818 Link Here
811
        }
811
        }
812
#endif
812
#endif
813
        if (debug_state)
813
        if (debug_state)
814
            log (LOG_DEBUG, "%s: Sending ICCN\n", __FUNCTION__);
814
            _log (LOG_DEBUG, "%s: Sending ICCN\n", __FUNCTION__);
815
        log (LOG_LOG,
815
        _log (LOG_LOG,
816
             "%s: Call established with %s, Local: %d, Remote: %d, Serial: %d\n",
816
             "%s: Call established with %s, Local: %d, Remote: %d, Serial: %d\n",
817
             __FUNCTION__, IPADDY (t->peer.sin_addr), c->ourcid, c->cid,
817
             __FUNCTION__, IPADDY (t->peer.sin_addr), c->ourcid, c->cid,
818
             c->serno);
818
             c->serno);
Lines 871-891 Link Here
871
    case ICCN:
871
    case ICCN:
872
        if (c == t->self)
872
        if (c == t->self)
873
        {
873
        {
874
            log (LOG_DEBUG,
874
            _log (LOG_DEBUG,
875
                 "%s: Peer attempted ICCN on the actual tunnel, not the call",
875
                 "%s: Peer attempted ICCN on the actual tunnel, not the call",
876
                 __FUNCTION__);
876
                 __FUNCTION__);
877
            return -EINVAL;
877
            return -EINVAL;
878
        }
878
        }
879
        if (c->txspeed < 1)
879
        if (c->txspeed < 1)
880
        {
880
        {
881
            log (LOG_DEBUG,
881
            _log (LOG_DEBUG,
882
                 "%s: Peer did not specify transmit speed\n", __FUNCTION__);
882
                 "%s: Peer did not specify transmit speed\n", __FUNCTION__);
883
            c->needclose = -1;
883
            c->needclose = -1;
884
            return -EINVAL;
884
            return -EINVAL;
885
        };
885
        };
886
        if (c->frame < 1)
886
        if (c->frame < 1)
887
        {
887
        {
888
            log (LOG_DEBUG,
888
            _log (LOG_DEBUG,
889
                 "%s: Peer did not specify framing type\n", __FUNCTION__);
889
                 "%s: Peer did not specify framing type\n", __FUNCTION__);
890
            c->needclose = -1;
890
            c->needclose = -1;
891
            return -EINVAL;
891
            return -EINVAL;
Lines 949-955 Link Here
949
        }
949
        }
950
        start_pppd (c, po);
950
        start_pppd (c, po);
951
        opt_destroy (po);
951
        opt_destroy (po);
952
        log (LOG_LOG,
952
        _log (LOG_LOG,
953
             "%s: Call established with %s, Local: %d, Remote: %d, Serial: %d\n",
953
             "%s: Call established with %s, Local: %d, Remote: %d, Serial: %d\n",
954
             __FUNCTION__, IPADDY (t->peer.sin_addr), c->ourcid, c->cid,
954
             __FUNCTION__, IPADDY (t->peer.sin_addr), c->ourcid, c->cid,
955
             c->serno);
955
             c->serno);
Lines 1007-1013 Link Here
1007
        };
1007
        };
1008
        start_pppd (c, po);
1008
        start_pppd (c, po);
1009
1009
1010
        log (LOG_LOG, "parameters: Local: %d , Remote: %d , Serial: %d , Pid: %d , Tunnelid: %d , Phoneid: %s\n", c->ourcid, c->cid, c->serno, c->pppd, t->ourtid, c->dial_no); /*  jz: just show some information */
1010
        _log (LOG_LOG, "parameters: Local: %d , Remote: %d , Serial: %d , Pid: %d , Tunnelid: %d , Phoneid: %s\n", c->ourcid, c->cid, c->serno, c->pppd, t->ourtid, c->dial_no); /*  jz: just show some information */
1011
1011
1012
        opt_destroy (po);
1012
        opt_destroy (po);
1013
        if (c->lac)
1013
        if (c->lac)
Lines 1019-1025 Link Here
1019
        if (c->qcid < 0)
1019
        if (c->qcid < 0)
1020
        {
1020
        {
1021
            if (DEBUG)
1021
            if (DEBUG)
1022
                log (LOG_DEBUG,
1022
                _log (LOG_DEBUG,
1023
                     "%s: Peer tried to disconnect without specifying call ID\n",
1023
                     "%s: Peer tried to disconnect without specifying call ID\n",
1024
                     __FUNCTION__);
1024
                     __FUNCTION__);
1025
            return -EINVAL;
1025
            return -EINVAL;
Lines 1032-1038 Link Here
1032
            if (!p)
1032
            if (!p)
1033
            {
1033
            {
1034
                if (DEBUG)
1034
                if (DEBUG)
1035
                    log (LOG_DEBUG,
1035
                    _log (LOG_DEBUG,
1036
                         "%s: Unable to determine call to be disconnected.\n",
1036
                         "%s: Unable to determine call to be disconnected.\n",
1037
                         __FUNCTION__);
1037
                         __FUNCTION__);
1038
                return -EINVAL;
1038
                return -EINVAL;
Lines 1043-1049 Link Here
1043
        if ((c->qcid != p->cid) && p->cid > 0)
1043
        if ((c->qcid != p->cid) && p->cid > 0)
1044
        {
1044
        {
1045
            if (DEBUG)
1045
            if (DEBUG)
1046
                log (LOG_DEBUG,
1046
                _log (LOG_DEBUG,
1047
                     "%s: Peer tried to disconnect with invalid CID (%d != %d)\n",
1047
                     "%s: Peer tried to disconnect with invalid CID (%d != %d)\n",
1048
                     __FUNCTION__, c->qcid, c->cid);
1048
                     __FUNCTION__, c->qcid, c->cid);
1049
            return -EINVAL;
1049
            return -EINVAL;
Lines 1052-1063 Link Here
1052
        if (c->result < 0)
1052
        if (c->result < 0)
1053
        {
1053
        {
1054
            if (DEBUG)
1054
            if (DEBUG)
1055
                log (LOG_DEBUG,
1055
                _log (LOG_DEBUG,
1056
                     "%s: Peer tried to disconnect without specifying result code.\n",
1056
                     "%s: Peer tried to disconnect without specifying result code.\n",
1057
                     __FUNCTION__);
1057
                     __FUNCTION__);
1058
            return -EINVAL;
1058
            return -EINVAL;
1059
        }
1059
        }
1060
        log (LOG_LOG,
1060
        _log (LOG_LOG,
1061
             "%s: Connection closed to %s, serial %d (%s)\n", __FUNCTION__,
1061
             "%s: Connection closed to %s, serial %d (%s)\n", __FUNCTION__,
1062
             IPADDY (t->peer.sin_addr), c->serno, c->errormsg);
1062
             IPADDY (t->peer.sin_addr), c->serno, c->errormsg);
1063
        c->needclose = 0;
1063
        c->needclose = 0;
Lines 1068-1074 Link Here
1068
    case SLI:
1068
    case SLI:
1069
        break;
1069
        break;
1070
    default:
1070
    default:
1071
        log (LOG_DEBUG,
1071
        _log (LOG_DEBUG,
1072
             "%s: Don't know how to finish a message of type %d\n",
1072
             "%s: Don't know how to finish a message of type %d\n",
1073
             __FUNCTION__, c->msgtype);
1073
             __FUNCTION__, c->msgtype);
1074
        set_error (c, VENDOR_ERROR, "Unimplemented message %d\n", c->msgtype);
1074
        set_error (c, VENDOR_ERROR, "Unimplemented message %d\n", c->msgtype);
Lines 1089-1095 Link Here
1089
    {
1089
    {
1090
        if (DEBUG)
1090
        if (DEBUG)
1091
        {
1091
        {
1092
            log (LOG_DEBUG,
1092
            _log (LOG_DEBUG,
1093
                 "%s: Received too small of packet\n", __FUNCTION__);
1093
                 "%s: Received too small of packet\n", __FUNCTION__);
1094
        }
1094
        }
1095
        return -EINVAL;
1095
        return -EINVAL;
Lines 1099-1105 Link Here
1099
    {
1099
    {
1100
        if (DEBUG)
1100
        if (DEBUG)
1101
        {
1101
        {
1102
            log (LOG_DEBUG,
1102
            _log (LOG_DEBUG,
1103
                 "%s: Reported and actual sizes differ (%d != %d)\n",
1103
                 "%s: Reported and actual sizes differ (%d != %d)\n",
1104
                 __FUNCTION__, h->length, buf->len);
1104
                 __FUNCTION__, h->length, buf->len);
1105
        }
1105
        }
Lines 1109-1121 Link Here
1109
     * FIXME: H-bit handling goes here
1109
     * FIXME: H-bit handling goes here
1110
     */
1110
     */
1111
#ifdef DEBUG_CONTROL
1111
#ifdef DEBUG_CONTROL
1112
    log (LOG_DEBUG, "%s: control, cid = %d, Ns = %d, Nr = %d\n", __FUNCTION__,
1112
    _log (LOG_DEBUG, "%s: control, cid = %d, Ns = %d, Nr = %d\n", __FUNCTION__,
1113
         c->cid, h->Ns, h->Nr);
1113
         c->cid, h->Ns, h->Nr);
1114
#endif
1114
#endif
1115
    if (h->Ns != t->control_rec_seq_num)
1115
    if (h->Ns != t->control_rec_seq_num)
1116
    {
1116
    {
1117
        if (DEBUG)
1117
        if (DEBUG)
1118
            log (LOG_DEBUG,
1118
            _log (LOG_DEBUG,
1119
                 "%s: Received out of order control packet on tunnel %d (%d != %d)\n",
1119
                 "%s: Received out of order control packet on tunnel %d (%d != %d)\n",
1120
                 __FUNCTION__, t->tid, h->Ns, t->control_rec_seq_num);
1120
                 __FUNCTION__, t->tid, h->Ns, t->control_rec_seq_num);
1121
        if (((h->Ns < t->control_rec_seq_num) && 
1121
        if (((h->Ns < t->control_rec_seq_num) && 
Lines 1130-1136 Link Here
1130
             */
1130
             */
1131
#ifdef DEBUG_ZLB
1131
#ifdef DEBUG_ZLB
1132
            if (DEBUG)
1132
            if (DEBUG)
1133
                log (LOG_DEBUG, "%s: Sending an updated ZLB in reponse\n",
1133
                _log (LOG_DEBUG, "%s: Sending an updated ZLB in reponse\n",
1134
                     __FUNCTION__);
1134
                     __FUNCTION__);
1135
#endif
1135
#endif
1136
            zlb = new_outgoing (t);
1136
            zlb = new_outgoing (t);
Lines 1164-1170 Link Here
1164
        {
1164
        {
1165
            if (DEBUG)
1165
            if (DEBUG)
1166
            {
1166
            {
1167
                log (LOG_DEBUG, "%s: Control bit not set\n", __FUNCTION__);
1167
                _log (LOG_DEBUG, "%s: Control bit not set\n", __FUNCTION__);
1168
            }
1168
            }
1169
            return -EINVAL;
1169
            return -EINVAL;
1170
        }
1170
        }
Lines 1172-1178 Link Here
1172
        {
1172
        {
1173
            if (DEBUG)
1173
            if (DEBUG)
1174
            {
1174
            {
1175
                log (LOG_DEBUG, "%s: Length bit not set\n", __FUNCTION__);
1175
                _log (LOG_DEBUG, "%s: Length bit not set\n", __FUNCTION__);
1176
            }
1176
            }
1177
            return -EINVAL;
1177
            return -EINVAL;
1178
        }
1178
        }
Lines 1180-1186 Link Here
1180
        {
1180
        {
1181
            if (DEBUG)
1181
            if (DEBUG)
1182
            {
1182
            {
1183
                log (LOG_DEBUG, "%s: Flow bit not set\n", __FUNCTION__);
1183
                _log (LOG_DEBUG, "%s: Flow bit not set\n", __FUNCTION__);
1184
            }
1184
            }
1185
            return -EINVAL;
1185
            return -EINVAL;
1186
        }
1186
        }
Lines 1190-1206 Link Here
1190
            {
1190
            {
1191
                if (CVER (h->ver) == VER_PPTP)
1191
                if (CVER (h->ver) == VER_PPTP)
1192
                {
1192
                {
1193
                    log (LOG_DEBUG,
1193
                    _log (LOG_DEBUG,
1194
                         "%s: PPTP packet received\n", __FUNCTION__);
1194
                         "%s: PPTP packet received\n", __FUNCTION__);
1195
                }
1195
                }
1196
                else if (CVER (h->ver) < VER_L2TP)
1196
                else if (CVER (h->ver) < VER_L2TP)
1197
                {
1197
                {
1198
                    log (LOG_DEBUG,
1198
                    _log (LOG_DEBUG,
1199
                         "%s: L2F packet received\n", __FUNCTION__);
1199
                         "%s: L2F packet received\n", __FUNCTION__);
1200
                }
1200
                }
1201
                else
1201
                else
1202
                {
1202
                {
1203
                    log (LOG_DEBUG,
1203
                    _log (LOG_DEBUG,
1204
                         "%s: Unknown version received\n", __FUNCTION__);
1204
                         "%s: Unknown version received\n", __FUNCTION__);
1205
                }
1205
                }
1206
            }
1206
            }
Lines 1226-1232 Link Here
1226
    {
1226
    {
1227
        if (DEBUG)
1227
        if (DEBUG)
1228
        {
1228
        {
1229
            log (LOG_DEBUG, "%s: Aempted to send payload on tunnel\n",
1229
            _log (LOG_DEBUG, "%s: Aempted to send payload on tunnel\n",
1230
                 __FUNCTION__);
1230
                 __FUNCTION__);
1231
        }
1231
        }
1232
        return -EINVAL;
1232
        return -EINVAL;
Lines 1237-1243 Link Here
1237
           no matter what.  we'll look more later */
1237
           no matter what.  we'll look more later */
1238
        if (DEBUG)
1238
        if (DEBUG)
1239
        {
1239
        {
1240
            log (LOG_DEBUG, "%s:Recieved to small of packet\n", __FUNCTION__);
1240
            _log (LOG_DEBUG, "%s:Recieved to small of packet\n", __FUNCTION__);
1241
        }
1241
        }
1242
        return -EINVAL;
1242
        return -EINVAL;
1243
    }
1243
    }
Lines 1248-1254 Link Here
1248
        {
1248
        {
1249
            if (DEBUG)
1249
            if (DEBUG)
1250
            {
1250
            {
1251
                log (LOG_DEBUG, "%s Control bit set\n", __FUNCTION__);
1251
                _log (LOG_DEBUG, "%s Control bit set\n", __FUNCTION__);
1252
            }
1252
            }
1253
            return -EINVAL;
1253
            return -EINVAL;
1254
        }
1254
        }
Lines 1258-1264 Link Here
1258
        {
1258
        {
1259
/*			if (!c->fbit && !c->ourfbit) {
1259
/*			if (!c->fbit && !c->ourfbit) {
1260
				if (DEBUG)
1260
				if (DEBUG)
1261
					log(LOG_DEBUG,"%s: flow bit set, but no RWS negotiated.\n",__FUNCTION__);
1261
					_log(LOG_DEBUG,"%s: flow bit set, but no RWS negotiated.\n",__FUNCTION__);
1262
				return -EINVAL;
1262
				return -EINVAL;
1263
			} */
1263
			} */
1264
            ehlen += 4;         /* Should have Ns and Nr too */
1264
            ehlen += 4;         /* Should have Ns and Nr too */
Lines 1266-1272 Link Here
1266
/*		if (!PFBIT(h->ver)) {
1266
/*		if (!PFBIT(h->ver)) {
1267
			if (c->fbit || c->ourfbit) {
1267
			if (c->fbit || c->ourfbit) {
1268
				if (DEBUG)
1268
				if (DEBUG)
1269
					log(LOG_DEBUG, "%s: no flow bit, but RWS was negotiated.\n",__FUNCTION__);
1269
					_log(LOG_DEBUG, "%s: no flow bit, but RWS was negotiated.\n",__FUNCTION__);
1270
				return -EINVAL;;
1270
				return -EINVAL;;
1271
			}
1271
			}
1272
		} */
1272
		} */
Lines 1280-1296 Link Here
1280
            {
1280
            {
1281
                if (PVER (h->ver) == VER_PPTP)
1281
                if (PVER (h->ver) == VER_PPTP)
1282
                {
1282
                {
1283
                    log (LOG_DEBUG, "%s: PPTP packet received\n",
1283
                    _log (LOG_DEBUG, "%s: PPTP packet received\n",
1284
                         __FUNCTION__);
1284
                         __FUNCTION__);
1285
                }
1285
                }
1286
                else if (CVER (h->ver) < VER_L2TP)
1286
                else if (CVER (h->ver) < VER_L2TP)
1287
                {
1287
                {
1288
                    log (LOG_DEBUG, "%s: L2F packet received\n",
1288
                    _log (LOG_DEBUG, "%s: L2F packet received\n",
1289
                         __FUNCTION__);
1289
                         __FUNCTION__);
1290
                }
1290
                }
1291
                else
1291
                else
1292
                {
1292
                {
1293
                    log (LOG_DEBUG, "%s: Unknown version received\n",
1293
                    _log (LOG_DEBUG, "%s: Unknown version received\n",
1294
                         __FUNCTION__);
1294
                         __FUNCTION__);
1295
                }
1295
                }
1296
            }
1296
            }
Lines 1300-1306 Link Here
1300
        {
1300
        {
1301
            if (DEBUG)
1301
            if (DEBUG)
1302
            {
1302
            {
1303
                log (LOG_DEBUG, "%s payload too small (%d < %d)\n",
1303
                _log (LOG_DEBUG, "%s payload too small (%d < %d)\n",
1304
                     __FUNCTION__, buf->len, ehlen);
1304
                     __FUNCTION__, buf->len, ehlen);
1305
            }
1305
            }
1306
            return -EINVAL;
1306
            return -EINVAL;
Lines 1309-1315 Link Here
1309
        {
1309
        {
1310
            if (DEBUG)
1310
            if (DEBUG)
1311
            {
1311
            {
1312
                log (LOG_DEBUG, "%s: size mismatch (%d != %d)\n",
1312
                _log (LOG_DEBUG, "%s: size mismatch (%d != %d)\n",
1313
                     __FUNCTION__, buf->len, h->length);
1313
                     __FUNCTION__, buf->len, h->length);
1314
            }
1314
            }
1315
            return -EINVAL;
1315
            return -EINVAL;
Lines 1347-1353 Link Here
1347
        new_hdr = (struct payload_hdr *) (buf->start - ehlen);
1347
        new_hdr = (struct payload_hdr *) (buf->start - ehlen);
1348
        if ((void *) new_hdr < (void *) buf->rstart)
1348
        if ((void *) new_hdr < (void *) buf->rstart)
1349
        {
1349
        {
1350
            log (LOG_WARN, "%s: not enough space to decompress frame\n",
1350
            _log (LOG_WARN, "%s: not enough space to decompress frame\n",
1351
                 __FUNCTION__);
1351
                 __FUNCTION__);
1352
            return -EINVAL;
1352
            return -EINVAL;
1353
1353
Lines 1399-1414 Link Here
1399
     */
1399
     */
1400
/*  JLM	if (PRBIT(new_hdr->ver)) {
1400
/*  JLM	if (PRBIT(new_hdr->ver)) {
1401
		if (c->pSr > new_hdr->Ns) {
1401
		if (c->pSr > new_hdr->Ns) {
1402
			log(LOG_DEBUG, "%s: R-bit set with Ns < pSr!\n",__FUNCTION__);
1402
			_log(LOG_DEBUG, "%s: R-bit set with Ns < pSr!\n",__FUNCTION__);
1403
			return -EINVAL;
1403
			return -EINVAL;
1404
		}
1404
		}
1405
#ifdef DEBUG_FLOW
1405
#ifdef DEBUG_FLOW
1406
		log(LOG_DEBUG, "%s: R-bit set on packet %d\n",__FUNCTION__,new_hdr->Ns);
1406
		_log(LOG_DEBUG, "%s: R-bit set on packet %d\n",__FUNCTION__,new_hdr->Ns);
1407
#endif
1407
#endif
1408
		c->pSr=new_hdr->Ns;
1408
		c->pSr=new_hdr->Ns;
1409
	} */
1409
	} */
1410
#ifdef DEBUG_PAYLOAD
1410
#ifdef DEBUG_PAYLOAD
1411
    log (LOG_DEBUG, "%s: payload, cid = %d, Ns = %d, Nr = %d\n", __FUNCTION__,
1411
    _log (LOG_DEBUG, "%s: payload, cid = %d, Ns = %d, Nr = %d\n", __FUNCTION__,
1412
         c->cid, new_hdr->Ns, new_hdr->Nr);
1412
         c->cid, new_hdr->Ns, new_hdr->Nr);
1413
#endif
1413
#endif
1414
    if (new_hdr->Ns != c->data_seq_num)
1414
    if (new_hdr->Ns != c->data_seq_num)
Lines 1421-1427 Link Here
1421
        {
1421
        {
1422
#ifdef DEBUG_FLOW
1422
#ifdef DEBUG_FLOW
1423
            if (DEBUG)
1423
            if (DEBUG)
1424
                log (LOG_DEBUG,
1424
                _log (LOG_DEBUG,
1425
                     "%s: Already seen this packet before (%d < %d)\n",
1425
                     "%s: Already seen this packet before (%d < %d)\n",
1426
                     __FUNCTION__, new_hdr->Ns, c->pSr);
1426
                     __FUNCTION__, new_hdr->Ns, c->pSr);
1427
#endif
1427
#endif
Lines 1432-1438 Link Here
1432
            /* FIXME: I should buffer for out of order packets */
1432
            /* FIXME: I should buffer for out of order packets */
1433
#ifdef DEBUG_FLOW
1433
#ifdef DEBUG_FLOW
1434
            if (DEBUG)
1434
            if (DEBUG)
1435
                log (LOG_DEBUG,
1435
                _log (LOG_DEBUG,
1436
                     "%s: Oops, lost a packet or two (%d != %d).  continuing...\n",
1436
                     "%s: Oops, lost a packet or two (%d != %d).  continuing...\n",
1437
                     __FUNCTION__, new_hdr->Ns, c->pSr);
1437
                     __FUNCTION__, new_hdr->Ns, c->pSr);
1438
#endif
1438
#endif
Lines 1442-1448 Link Here
1442
        {
1442
        {
1443
#ifdef DEBUG_FLOW
1443
#ifdef DEBUG_FLOW
1444
            if (DEBUG)
1444
            if (DEBUG)
1445
                log (LOG_DEBUG,
1445
                _log (LOG_DEBUG,
1446
                     "%s: Received out of order payload packet (%d != %d)\n",
1446
                     "%s: Received out of order payload packet (%d != %d)\n",
1447
                     __FUNCTION__, new_hdr->Ns, c->pSr);
1447
                     __FUNCTION__, new_hdr->Ns, c->pSr);
1448
#endif
1448
#endif
Lines 1475-1487 Link Here
1475
    c = (struct call *) data;
1475
    c = (struct call *) data;
1476
    if (!c)
1476
    if (!c)
1477
    {
1477
    {
1478
        log (LOG_WARN, "%s: called on NULL call\n", __FUNCTION__);
1478
        _log (LOG_WARN, "%s: called on NULL call\n", __FUNCTION__);
1479
        return;
1479
        return;
1480
    }
1480
    }
1481
    t = c->container;
1481
    t = c->container;
1482
    if (!t)
1482
    if (!t)
1483
    {
1483
    {
1484
        log (LOG_WARN, "%s: called on call with NULL container\n",
1484
        _log (LOG_WARN, "%s: called on call with NULL container\n",
1485
             __FUNCTION__);
1485
             __FUNCTION__);
1486
        return;
1486
        return;
1487
    }
1487
    }
Lines 1492-1498 Link Here
1492
    c->data_seq_num--;                   /* We don't increment on ZLB's */
1492
    c->data_seq_num--;                   /* We don't increment on ZLB's */
1493
    c->zlb_xmit = NULL;
1493
    c->zlb_xmit = NULL;
1494
#ifdef DEBUG_ZLB
1494
#ifdef DEBUG_ZLB
1495
    log (LOG_DEBUG, "%s: sending payload ZLB\n", __FUNCTION__);
1495
    _log (LOG_DEBUG, "%s: sending payload ZLB\n", __FUNCTION__);
1496
#endif
1496
#endif
1497
    udp_xmit (buf);
1497
    udp_xmit (buf);
1498
    toss (buf);
1498
    toss (buf);
Lines 1514-1520 Link Here
1514
    if (c->fd < 0)
1514
    if (c->fd < 0)
1515
    {
1515
    {
1516
        if (DEBUG)
1516
        if (DEBUG)
1517
            log (LOG_DEBUG, "%s: tty is not open yet.\n", __FUNCTION__);
1517
            _log (LOG_DEBUG, "%s: tty is not open yet.\n", __FUNCTION__);
1518
        return -EIO;
1518
        return -EIO;
1519
    }
1519
    }
1520
    /*
1520
    /*
Lines 1541-1547 Link Here
1541
        }
1541
        }
1542
        else if (err == 0)
1542
        else if (err == 0)
1543
        {
1543
        {
1544
            log (LOG_WARN, "%s: wrote no bytes of async packet\n",
1544
            _log (LOG_WARN, "%s: wrote no bytes of async packet\n",
1545
                 __FUNCTION__);
1545
                 __FUNCTION__);
1546
            return -EINVAL;
1546
            return -EINVAL;
1547
        }
1547
        }
Lines 1553-1571 Link Here
1553
            }
1553
            }
1554
            else
1554
            else
1555
            {
1555
            {
1556
                log (LOG_WARN, "%s: async write failed: %s\n", __FUNCTION__,
1556
                _log (LOG_WARN, "%s: async write failed: %s\n", __FUNCTION__,
1557
                     strerror (errno));
1557
                     strerror (errno));
1558
            }
1558
            }
1559
        }
1559
        }
1560
        else if (err < buf->len)
1560
        else if (err < buf->len)
1561
        {
1561
        {
1562
            log (LOG_WARN, "%s: short write (%d of %d bytes)\n", __FUNCTION__,
1562
            _log (LOG_WARN, "%s: short write (%d of %d bytes)\n", __FUNCTION__,
1563
                 err, buf->len);
1563
                 err, buf->len);
1564
            return -EINVAL;
1564
            return -EINVAL;
1565
        }
1565
        }
1566
        else if (err > buf->len)
1566
        else if (err > buf->len)
1567
        {
1567
        {
1568
            log (LOG_WARN, "%s: write returned LONGER than buffer length?\n",
1568
            _log (LOG_WARN, "%s: write returned LONGER than buffer length?\n",
1569
                 __FUNCTION__);
1569
                 __FUNCTION__);
1570
            return -EINVAL;
1570
            return -EINVAL;
1571
        }
1571
        }
Lines 1603-1609 Link Here
1603
               * everything ended normally
1603
               * everything ended normally
1604
             */
1604
             */
1605
            if (DEBUG)
1605
            if (DEBUG)
1606
                log (LOG_WARN, "%s: %s(%d)\n", __FUNCTION__, strerror (errno),
1606
                _log (LOG_WARN, "%s: %s(%d)\n", __FUNCTION__, strerror (errno),
1607
                     errno);
1607
                     errno);
1608
            c->needclose = -1;
1608
            c->needclose = -1;
1609
            c->fd = -1;
1609
            c->fd = -1;
Lines 1637-1643 Link Here
1637
        {
1637
        {
1638
            /* If it's a ZLB, we ignore it */
1638
            /* If it's a ZLB, we ignore it */
1639
            if (debug_tunnel)
1639
            if (debug_tunnel)
1640
                log (LOG_DEBUG, "%s: ZLB for closed call\n", __FUNCTION__);
1640
                _log (LOG_DEBUG, "%s: ZLB for closed call\n", __FUNCTION__);
1641
            c->cid = 0;
1641
            c->cid = 0;
1642
            return;
1642
            return;
1643
        }
1643
        }
Lines 1653-1659 Link Here
1653
    {
1653
    {
1654
        c->cid = 0;
1654
        c->cid = 0;
1655
        if (debug_tunnel)
1655
        if (debug_tunnel)
1656
            log (LOG_DEBUG, "%s: invalid control packet\n", __FUNCTION__);
1656
            _log (LOG_DEBUG, "%s: invalid control packet\n", __FUNCTION__);
1657
    }
1657
    }
1658
}
1658
}
1659
1659
Lines 1671-1677 Link Here
1671
            if (buf->len == sizeof (struct control_hdr))
1671
            if (buf->len == sizeof (struct control_hdr))
1672
            {
1672
            {
1673
#ifdef DEBUG_ZLB
1673
#ifdef DEBUG_ZLB
1674
                log (LOG_DEBUG, "%s: control ZLB received\n", __FUNCTION__);
1674
                _log (LOG_DEBUG, "%s: control ZLB received\n", __FUNCTION__);
1675
#endif
1675
#endif
1676
                t->control_rec_seq_num--;
1676
                t->control_rec_seq_num--;
1677
                c->cnu = 0;
1677
                c->cnu = 0;
Lines 1680-1686 Link Here
1680
                    if (c->container->cLr >= c->closeSs)
1680
                    if (c->container->cLr >= c->closeSs)
1681
                    {
1681
                    {
1682
#ifdef DEBUG_ZLB
1682
#ifdef DEBUG_ZLB
1683
                        log (LOG_DEBUG, "%s: ZLB for closing message found\n",
1683
                        _log (LOG_DEBUG, "%s: ZLB for closing message found\n",
1684
                             __FUNCTION__);
1684
                             __FUNCTION__);
1685
#endif
1685
#endif
1686
                        c->needclose = 0;
1686
                        c->needclose = 0;
Lines 1696-1708 Link Here
1696
            else
1696
            else
1697
            {
1697
            {
1698
                if (debug_tunnel)
1698
                if (debug_tunnel)
1699
                    log (LOG_DEBUG, "%s: bad AVP handling!\n", __FUNCTION__);
1699
                    _log (LOG_DEBUG, "%s: bad AVP handling!\n", __FUNCTION__);
1700
                return -EINVAL;
1700
                return -EINVAL;
1701
            }
1701
            }
1702
        }
1702
        }
1703
        else
1703
        else
1704
        {
1704
        {
1705
            log (LOG_DEBUG, "%s: bad control packet!\n", __FUNCTION__);
1705
            _log (LOG_DEBUG, "%s: bad control packet!\n", __FUNCTION__);
1706
            return -EINVAL;
1706
            return -EINVAL;
1707
        }
1707
        }
1708
    }
1708
    }
Lines 1717-1727 Link Here
1717
/*					if (c->throttle) {
1717
/*					if (c->throttle) {
1718
						if (c->pSs > c->pLr + c->rws) {
1718
						if (c->pSs > c->pLr + c->rws) {
1719
#ifdef DEBUG_FLOW
1719
#ifdef DEBUG_FLOW
1720
							log(LOG_DEBUG, "%s: not yet dethrottling call\n",__FUNCTION__);
1720
							_log(LOG_DEBUG, "%s: not yet dethrottling call\n",__FUNCTION__);
1721
#endif
1721
#endif
1722
						} else {
1722
						} else {
1723
#ifdef DEBUG_FLOW
1723
#ifdef DEBUG_FLOW
1724
							log(LOG_DEBUG, "%s: dethrottling call\n",__FUNCTION__);
1724
							_log(LOG_DEBUG, "%s: dethrottling call\n",__FUNCTION__);
1725
#endif
1725
#endif
1726
							if (c->dethrottle) deschedule(c->dethrottle);
1726
							if (c->dethrottle) deschedule(c->dethrottle);
1727
							c->dethrottle=NULL;
1727
							c->dethrottle=NULL;
Lines 1743-1749 Link Here
1743
						We've received enough to fill our receive window.  At
1743
						We've received enough to fill our receive window.  At
1744
						this point, we should immediately send a ZLB!
1744
						this point, we should immediately send a ZLB!
1745
#ifdef DEBUG_ZLB
1745
#ifdef DEBUG_ZLB
1746
							log(LOG_DEBUG, "%s: Sending immediate ZLB!\n",__FUNCTION__);
1746
							_log(LOG_DEBUG, "%s: Sending immediate ZLB!\n",__FUNCTION__);
1747
#endif
1747
#endif
1748
							if (c->zlb_xmit) {
1748
							if (c->zlb_xmit) {
1749
							Deschedule any existing zlb_xmit's
1749
							Deschedule any existing zlb_xmit's
Lines 1760-1766 Link Here
1760
							if (c->zlb_xmit)
1760
							if (c->zlb_xmit)
1761
								deschedule(c->zlb_xmit);
1761
								deschedule(c->zlb_xmit);
1762
#ifdef DEBUG_ZLB
1762
#ifdef DEBUG_ZLB
1763
							log(LOG_DEBUG, "%s: scheduling ZLB\n",__FUNCTION__);
1763
							_log(LOG_DEBUG, "%s: scheduling ZLB\n",__FUNCTION__);
1764
#endif
1764
#endif
1765
							c->zlb_xmit = schedule(tv, &send_zlb, (void *)c);
1765
							c->zlb_xmit = schedule(tv, &send_zlb, (void *)c);
1766
						}
1766
						}
Lines 1770-1786 Link Here
1770
                else if (buf->len == sizeof (struct payload_hdr))
1770
                else if (buf->len == sizeof (struct payload_hdr))
1771
                {
1771
                {
1772
#ifdef DEBUG_ZLB
1772
#ifdef DEBUG_ZLB
1773
                    log (LOG_DEBUG, "%s: payload ZLB received\n",
1773
                    _log (LOG_DEBUG, "%s: payload ZLB received\n",
1774
                         __FUNCTION__);
1774
                         __FUNCTION__);
1775
#endif
1775
#endif
1776
/*					if (c->throttle) {
1776
/*					if (c->throttle) {
1777
						if (c->pSs > c->pLr + c->rws) {
1777
						if (c->pSs > c->pLr + c->rws) {
1778
#ifdef DEBUG_FLOW
1778
#ifdef DEBUG_FLOW
1779
							log(LOG_DEBUG, "%s: not yet dethrottling call\n",__FUNCTION__);
1779
							_log(LOG_DEBUG, "%s: not yet dethrottling call\n",__FUNCTION__);
1780
#endif
1780
#endif
1781
						} else {
1781
						} else {
1782
#ifdef DEBUG_FLOW
1782
#ifdef DEBUG_FLOW
1783
							log(LOG_DEBUG, "%s: dethrottling call\n",__FUNCTION__);
1783
							_log(LOG_DEBUG, "%s: dethrottling call\n",__FUNCTION__);
1784
#endif
1784
#endif
1785
							if (c->dethrottle)
1785
							if (c->dethrottle)
1786
								deschedule(c->dethrottle);
1786
								deschedule(c->dethrottle);
Lines 1793-1813 Link Here
1793
                }
1793
                }
1794
                else
1794
                else
1795
                {
1795
                {
1796
                    log (LOG_DEBUG, "%s: payload too small!\n", __FUNCTION__);
1796
                    _log (LOG_DEBUG, "%s: payload too small!\n", __FUNCTION__);
1797
                    return -EINVAL;
1797
                    return -EINVAL;
1798
                }
1798
                }
1799
            }
1799
            }
1800
            else
1800
            else
1801
            {
1801
            {
1802
                if (debug_tunnel)
1802
                if (debug_tunnel)
1803
                    log (LOG_DEBUG, "%s: unable to expand payload!\n",
1803
                    _log (LOG_DEBUG, "%s: unable to expand payload!\n",
1804
                         __FUNCTION__);
1804
                         __FUNCTION__);
1805
                return -EINVAL;
1805
                return -EINVAL;
1806
            }
1806
            }
1807
        }
1807
        }
1808
        else
1808
        else
1809
        {
1809
        {
1810
            log (LOG_DEBUG, "%s: invalid payload packet!\n", __FUNCTION__);
1810
            _log (LOG_DEBUG, "%s: invalid payload packet!\n", __FUNCTION__);
1811
            return -EINVAL;
1811
            return -EINVAL;
1812
        }
1812
        }
1813
    }
1813
    }
(-)l2tpd-0.69/file.c (-27 / +27 lines)
Lines 56-62 Link Here
56
        }
56
        }
57
        else
57
        else
58
        {
58
        {
59
            log (LOG_CRIT, "%s: Unable to open config file %s or %s\n",
59
            _log (LOG_CRIT, "%s: Unable to open config file %s or %s\n",
60
                 __FUNCTION__, gconfig.configfile, gconfig.altconfigfile);
60
                 __FUNCTION__, gconfig.configfile, gconfig.altconfigfile);
61
            return -1;
61
            return -1;
62
        }
62
        }
Lines 74-80 Link Here
74
    tmp = (struct lns *) malloc (sizeof (struct lns));
74
    tmp = (struct lns *) malloc (sizeof (struct lns));
75
    if (!tmp)
75
    if (!tmp)
76
    {
76
    {
77
        log (LOG_CRIT, "%s: Unable to allocate memory for new LNS\n",
77
        _log (LOG_CRIT, "%s: Unable to allocate memory for new LNS\n",
78
             __FUNCTION__);
78
             __FUNCTION__);
79
        return NULL;
79
        return NULL;
80
    }
80
    }
Lines 118-124 Link Here
118
    tmp = (struct lac *) malloc (sizeof (struct lac));
118
    tmp = (struct lac *) malloc (sizeof (struct lac));
119
    if (!tmp)
119
    if (!tmp)
120
    {
120
    {
121
        log (LOG_CRIT, "%s: Unable to allocate memory for lac entry!\n",
121
        _log (LOG_CRIT, "%s: Unable to allocate memory for lac entry!\n",
122
             __FUNCTION__);
122
             __FUNCTION__);
123
        return NULL;
123
        return NULL;
124
    }
124
    }
Lines 171-177 Link Here
171
{
171
{
172
    int val;
172
    int val;
173
#ifdef DEBUG_FILE
173
#ifdef DEBUG_FILE
174
    log (LOG_DEBUG, "set_%s: %s  flag to '%s'\n", word, word, value);
174
    _log (LOG_DEBUG, "set_%s: %s  flag to '%s'\n", word, word, value);
175
#endif /* ; */
175
#endif /* ; */
176
    if ((val = yesno (value)) < 0)
176
    if ((val = yesno (value)) < 0)
177
    {
177
    {
Lines 187-193 Link Here
187
{
187
{
188
    int val;
188
    int val;
189
#ifdef DEBUG_FILE
189
#ifdef DEBUG_FILE
190
    log (LOG_DEBUG, "set_%s: %s  flag to '%s'\n", word, word, value);
190
    _log (LOG_DEBUG, "set_%s: %s  flag to '%s'\n", word, word, value);
191
#endif /* ; */
191
#endif /* ; */
192
    if ((val = atoi (value)) < 0)
192
    if ((val = atoi (value)) < 0)
193
    {
193
    {
Lines 201-207 Link Here
201
int set_string (char *word, char *value, char *ptr, int len)
201
int set_string (char *word, char *value, char *ptr, int len)
202
{
202
{
203
#ifdef DEBUG_FILE
203
#ifdef DEBUG_FILE
204
    log (LOG_DEBUG, "set_%s: %s  flag to '%s'\n", word, word, value);
204
    _log (LOG_DEBUG, "set_%s: %s  flag to '%s'\n", word, word, value);
205
#endif /* ; */
205
#endif /* ; */
206
    strncpy (ptr, value, len);
206
    strncpy (ptr, value, len);
207
    return 0;
207
    return 0;
Lines 213-219 Link Here
213
    {
213
    {
214
    case CONTEXT_GLOBAL:
214
    case CONTEXT_GLOBAL:
215
#ifdef DEBUG_FILE
215
#ifdef DEBUG_FILE
216
        log (LOG_DEBUG, "set_port: Setting global port number to %s\n",
216
        _log (LOG_DEBUG, "set_port: Setting global port number to %s\n",
217
             value);
217
             value);
218
#endif
218
#endif
219
        set_int (word, value, &(((struct global *) item)->port));
219
        set_int (word, value, &(((struct global *) item)->port));
Lines 238-244 Link Here
238
    {
238
    {
239
    case CONTEXT_LAC:
239
    case CONTEXT_LAC:
240
#ifdef DEBUG_FILE
240
#ifdef DEBUG_FILE
241
        log (LOG_DEBUG, "set_rtimeout: Setting redial timeout to %s\n",
241
        _log (LOG_DEBUG, "set_rtimeout: Setting redial timeout to %s\n",
242
             value);
242
             value);
243
#endif
243
#endif
244
        set_int (word, value, &(((struct lac *) item)->rtimeout));
244
        set_int (word, value, &(((struct lac *) item)->rtimeout));
Lines 308-314 Link Here
308
    {
308
    {
309
    case CONTEXT_LAC:
309
    case CONTEXT_LAC:
310
#ifdef DEBUG_FILE
310
#ifdef DEBUG_FILE
311
        log (LOG_DEBUG, "set_rmax: Setting max redials to %s\n", value);
311
        _log (LOG_DEBUG, "set_rmax: Setting max redials to %s\n", value);
312
#endif
312
#endif
313
        set_int (word, value, &(((struct lac *) item)->rmax));
313
        set_int (word, value, &(((struct lac *) item)->rmax));
314
        break;
314
        break;
Lines 332-338 Link Here
332
    {
332
    {
333
    case CONTEXT_GLOBAL:
333
    case CONTEXT_GLOBAL:
334
#ifdef DEBUG_FILE
334
#ifdef DEBUG_FILE
335
        log (LOG_DEBUG, "set_authfile: Setting global auth file to '%s'\n",
335
        _log (LOG_DEBUG, "set_authfile: Setting global auth file to '%s'\n",
336
             value);
336
             value);
337
#endif /* ; */
337
#endif /* ; */
338
        strncpy (((struct global *) item)->authfile, value,
338
        strncpy (((struct global *) item)->authfile, value,
Lines 763-769 Link Here
763
    if (!lns->range)
763
    if (!lns->range)
764
        return -1;
764
        return -1;
765
#ifdef DEBUG_FILE
765
#ifdef DEBUG_FILE
766
    log (LOG_DEBUG, "range start = %x, end = %x, sense=%ud\n",
766
    _log (LOG_DEBUG, "range start = %x, end = %x, sense=%ud\n",
767
         ntohl (ipr->start), ntohl (ipr->end), ipr->sense);
767
         ntohl (ipr->start), ntohl (ipr->end), ipr->sense);
768
#endif
768
#endif
769
    return 0;
769
    return 0;
Lines 785-791 Link Here
785
    if (!lns->lacs)
785
    if (!lns->lacs)
786
        return -1;
786
        return -1;
787
#ifdef DEBUG_FILE
787
#ifdef DEBUG_FILE
788
    log (LOG_DEBUG, "lac start = %x, end = %x, sense=%ud\n",
788
    _log (LOG_DEBUG, "lac start = %x, end = %x, sense=%ud\n",
789
         ntohl (ipr->start), ntohl (ipr->end), ipr->sense);
789
         ntohl (ipr->start), ntohl (ipr->end), ipr->sense);
790
#endif
790
#endif
791
    return 0;
791
    return 0;
Lines 867-873 Link Here
867
    {
867
    {
868
    case CONTEXT_LAC:
868
    case CONTEXT_LAC:
869
#ifdef DEBUG_FILE
869
#ifdef DEBUG_FILE
870
        log (LOG_DEBUG, "set_lns: setting LNS to '%s'\n", value);
870
        _log (LOG_DEBUG, "set_lns: setting LNS to '%s'\n", value);
871
#endif
871
#endif
872
        l = (struct lac *) item;
872
        l = (struct lac *) item;
873
        d = strchr (value, ':');
873
        d = strchr (value, ':');
Lines 911-917 Link Here
911
911
912
int set_rand_sys ()
912
int set_rand_sys ()
913
{
913
{
914
    log(LOG_WARN, "The \"rand()\" function call is not a very good source"
914
    _log(LOG_WARN, "The \"rand()\" function call is not a very good source"
915
            "of randomness\n");
915
            "of randomness\n");
916
   rand_source = RAND_SYS;
916
   rand_source = RAND_SYS;
917
    return 0;
917
    return 0;
Lines 925-931 Link Here
925
925
926
int set_rand_egd (char *value)
926
int set_rand_egd (char *value)
927
{
927
{
928
    log(LOG_WARN, "%s: not yet implemented!\n", __FUNCTION__);
928
    _log(LOG_WARN, "%s: not yet implemented!\n", __FUNCTION__);
929
    rand_source = RAND_EGD;
929
    rand_source = RAND_EGD;
930
    return -1;
930
    return -1;
931
}
931
}
Lines 953-959 Link Here
953
 
953
 
954
    if (context != CONTEXT_GLOBAL)
954
    if (context != CONTEXT_GLOBAL)
955
    {
955
    {
956
        log(LOG_WARN, "%s: %s not valid in context %d\n",
956
        _log(LOG_WARN, "%s: %s not valid in context %d\n",
957
                __FUNCTION__, word, context);
957
                __FUNCTION__, word, context);
958
        return -1;
958
        return -1;
959
    }
959
    }
Lines 977-983 Link Here
977
    }
977
    }
978
    else
978
    else
979
    {
979
    {
980
        log(LOG_WARN, "%s: %s is not a valid randomness source\n",
980
        _log(LOG_WARN, "%s: %s is not a valid randomness source\n",
981
                __FUNCTION__, value);
981
                __FUNCTION__, value);
982
        return -1;
982
        return -1;
983
983
Lines 1023-1029 Link Here
1023
            /* We've got a context description */
1023
            /* We've got a context description */
1024
            if (!(t = strchr (s, ']')))
1024
            if (!(t = strchr (s, ']')))
1025
            {
1025
            {
1026
                log (LOG_CRIT, "parse_config: line %d: No closing bracket\n",
1026
                _log (LOG_CRIT, "parse_config: line %d: No closing bracket\n",
1027
                     linenum);
1027
                     linenum);
1028
                return -1;
1028
                return -1;
1029
            }
1029
            }
Lines 1043-1049 Link Here
1043
            {
1043
            {
1044
                context = CONTEXT_GLOBAL;
1044
                context = CONTEXT_GLOBAL;
1045
#ifdef DEBUG_FILE
1045
#ifdef DEBUG_FILE
1046
                log (LOG_DEBUG,
1046
                _log (LOG_DEBUG,
1047
                     "parse_config: global context descriptor %s\n",
1047
                     "parse_config: global context descriptor %s\n",
1048
                     d ? d : "");
1048
                     d ? d : "");
1049
#endif
1049
#endif
Lines 1088-1094 Link Here
1088
                    strncpy (((struct lns *) data)->entname,
1088
                    strncpy (((struct lns *) data)->entname,
1089
                             d, sizeof (((struct lns *) data)->entname));
1089
                             d, sizeof (((struct lns *) data)->entname));
1090
#ifdef DEBUG_FILE
1090
#ifdef DEBUG_FILE
1091
                log (LOG_DEBUG, "parse_config: lns context descriptor %s\n",
1091
                _log (LOG_DEBUG, "parse_config: lns context descriptor %s\n",
1092
                     d ? d : "");
1092
                     d ? d : "");
1093
#endif
1093
#endif
1094
            }
1094
            }
Lines 1131-1143 Link Here
1131
                    strncpy (((struct lac *) data)->entname,
1131
                    strncpy (((struct lac *) data)->entname,
1132
                             d, sizeof (((struct lac *) data)->entname));
1132
                             d, sizeof (((struct lac *) data)->entname));
1133
#ifdef DEBUG_FILE
1133
#ifdef DEBUG_FILE
1134
                log (LOG_DEBUG, "parse_config: lac context descriptor %s\n",
1134
                _log (LOG_DEBUG, "parse_config: lac context descriptor %s\n",
1135
                     d ? d : "");
1135
                     d ? d : "");
1136
#endif
1136
#endif
1137
            }
1137
            }
1138
            else
1138
            else
1139
            {
1139
            {
1140
                log (LOG_WARN,
1140
                _log (LOG_WARN,
1141
                     "parse_config: line %d: unknown context '%s'\n", linenum,
1141
                     "parse_config: line %d: unknown context '%s'\n", linenum,
1142
                     s);
1142
                     s);
1143
                return -1;
1143
                return -1;
Lines 1147-1160 Link Here
1147
        {
1147
        {
1148
            if (!context)
1148
            if (!context)
1149
            {
1149
            {
1150
                log (LOG_WARN,
1150
                _log (LOG_WARN,
1151
                     "parse_config: line %d: data '%s' occurs with no context\n",
1151
                     "parse_config: line %d: data '%s' occurs with no context\n",
1152
                     linenum, s);
1152
                     linenum, s);
1153
                return -1;
1153
                return -1;
1154
            }
1154
            }
1155
            if (!(t = strchr (s, '=')))
1155
            if (!(t = strchr (s, '=')))
1156
            {
1156
            {
1157
                log (LOG_WARN, "parse_config: line %d: no '=' in data\n",
1157
                _log (LOG_WARN, "parse_config: line %d: no '=' in data\n",
1158
                     linenum);
1158
                     linenum);
1159
                return -1;
1159
                return -1;
1160
            }
1160
            }
Lines 1168-1174 Link Here
1168
            while (*t && (*t < 33))
1168
            while (*t && (*t < 33))
1169
                t++;
1169
                t++;
1170
#ifdef DEBUG_FILE
1170
#ifdef DEBUG_FILE
1171
            log (LOG_DEBUG, "parse_config: field is %s, value is %s\n", s, t);
1171
            _log (LOG_DEBUG, "parse_config: field is %s, value is %s\n", s, t);
1172
#endif
1172
#endif
1173
            /* Okay, bit twidling is done.  Let's handle this */
1173
            /* Okay, bit twidling is done.  Let's handle this */
1174
            for (kw = words; kw->keyword; kw++)
1174
            for (kw = words; kw->keyword; kw++)
Lines 1177-1183 Link Here
1177
                {
1177
                {
1178
                    if (kw->handler (s, t, context | def, data))
1178
                    if (kw->handler (s, t, context | def, data))
1179
                    {
1179
                    {
1180
                        log (LOG_WARN, "parse_config: line %d: %s", linenum,
1180
                        _log (LOG_WARN, "parse_config: line %d: %s", linenum,
1181
                             filerr);
1181
                             filerr);
1182
                        return -1;
1182
                        return -1;
1183
                    }
1183
                    }
Lines 1186-1192 Link Here
1186
            }
1186
            }
1187
            if (!kw->keyword)
1187
            if (!kw->keyword)
1188
            {
1188
            {
1189
                log (LOG_CRIT, "parse_config: line %d: Unknown field '%s'\n",
1189
                _log (LOG_CRIT, "parse_config: line %d: Unknown field '%s'\n",
1190
                     linenum, s);
1190
                     linenum, s);
1191
                return -1;
1191
                return -1;
1192
            }
1192
            }
(-)l2tpd-0.69/l2tpd.c (-57 / +57 lines)
Lines 71-77 Link Here
71
    FILE *f = fdopen (fd2, "a");
71
    FILE *f = fdopen (fd2, "a");
72
    if (!f)
72
    if (!f)
73
    {
73
    {
74
        log (LOG_WARN, "show_status: fdopen() failed on fd %d\n", fd);
74
        _log (LOG_WARN, "show_status: fdopen() failed on fd %d\n", fd);
75
        return;
75
        return;
76
    }
76
    }
77
    fprintf (f, "====== l2tpd statistics ========\n");
77
    fprintf (f, "====== l2tpd statistics ========\n");
Lines 207-213 Link Here
207
        {
207
        {
208
            if (c->pppd == pid)
208
            if (c->pppd == pid)
209
            {
209
            {
210
                log (LOG_DEBUG, "%s : pppd died for call %d\n", __FUNCTION__,
210
                _log (LOG_DEBUG, "%s : pppd died for call %d\n", __FUNCTION__,
211
                     c->cid);
211
                     c->cid);
212
                c->needclose = -1;
212
                c->needclose = -1;
213
                /* 
213
                /* 
Lines 233-239 Link Here
233
     */
233
     */
234
    struct tunnel *st, *st2;
234
    struct tunnel *st, *st2;
235
    int sec;
235
    int sec;
236
    log (LOG_CRIT, "%s: Fatal signal %d received\n", __FUNCTION__, signal);
236
    _log (LOG_CRIT, "%s: Fatal signal %d received\n", __FUNCTION__, signal);
237
    st = tunnels.head;
237
    st = tunnels.head;
238
    while (st)
238
    while (st)
239
    {
239
    {
Lines 285-296 Link Here
285
    stropt[pos] = NULL;
285
    stropt[pos] = NULL;
286
    if (c->pppd > 0)
286
    if (c->pppd > 0)
287
    {
287
    {
288
        log (LOG_WARN, "%s: PPP already started on call!\n", __FUNCTION__);
288
        _log (LOG_WARN, "%s: PPP already started on call!\n", __FUNCTION__);
289
        return -EINVAL;
289
        return -EINVAL;
290
    }
290
    }
291
    if (c->fd > -1)
291
    if (c->fd > -1)
292
    {
292
    {
293
        log (LOG_WARN, "%s: file descriptor already assigned!\n",
293
        _log (LOG_WARN, "%s: file descriptor already assigned!\n",
294
             __FUNCTION__);
294
             __FUNCTION__);
295
        return -EINVAL;
295
        return -EINVAL;
296
    }
296
    }
Lines 311-317 Link Here
311
#endif
311
#endif
312
        if ((c->fd = getPtyMaster (&a, &b)) < 0)
312
        if ((c->fd = getPtyMaster (&a, &b)) < 0)
313
        {
313
        {
314
            log (LOG_WARN, "%s: unable to allocate pty, abandoning!\n",
314
            _log (LOG_WARN, "%s: unable to allocate pty, abandoning!\n",
315
                 __FUNCTION__);
315
                 __FUNCTION__);
316
            return -EINVAL;
316
            return -EINVAL;
317
        }
317
        }
Lines 331-347 Link Here
331
#endif
331
#endif
332
    str = stropt[0];
332
    str = stropt[0];
333
#ifdef DEBUG_PPPD
333
#ifdef DEBUG_PPPD
334
    log (LOG_DEBUG, "%s: I'm running:  ", __FUNCTION__);
334
    _log (LOG_DEBUG, "%s: I'm running:  ", __FUNCTION__);
335
    for (x = 0; stropt[x]; x++)
335
    for (x = 0; stropt[x]; x++)
336
    {
336
    {
337
        log (LOG_DEBUG, "\"%s\" ", stropt[x]);
337
        _log (LOG_DEBUG, "\"%s\" ", stropt[x]);
338
    };
338
    };
339
    log (LOG_DEBUG, "\n");
339
    _log (LOG_DEBUG, "\n");
340
#endif
340
#endif
341
    c->pppd = fork ();
341
    c->pppd = fork ();
342
    if (c->pppd < 0)
342
    if (c->pppd < 0)
343
    {
343
    {
344
        log (LOG_WARN, "%s: unable to fork(), abandoning!\n", __FUNCTION__);
344
        _log (LOG_WARN, "%s: unable to fork(), abandoning!\n", __FUNCTION__);
345
        return -EINVAL;
345
        return -EINVAL;
346
    }
346
    }
347
    else if (!c->pppd)
347
    else if (!c->pppd)
Lines 358-364 Link Here
358
        if (fd2 < 0)
358
        if (fd2 < 0)
359
#endif
359
#endif
360
        {
360
        {
361
            log (LOG_WARN, "%s: Unable to open %s to launch pppd!\n",
361
            _log (LOG_WARN, "%s: Unable to open %s to launch pppd!\n",
362
                 __FUNCTION__, tty);
362
                 __FUNCTION__, tty);
363
            exit (1);
363
            exit (1);
364
        }
364
        }
Lines 386-392 Link Here
386
        close (control_fd);
386
        close (control_fd);
387
387
388
        execv (PPPD, stropt);
388
        execv (PPPD, stropt);
389
        log (LOG_WARN, "%s: Exec of %s failed!\n", __FUNCTION__, PPPD);
389
        _log (LOG_WARN, "%s: Exec of %s failed!\n", __FUNCTION__, PPPD);
390
        exit (1);
390
        exit (1);
391
    };
391
    };
392
    close (fd2);
392
    close (fd2);
Lines 455-468 Link Here
455
            }
455
            }
456
            else
456
            else
457
            {
457
            {
458
                log (LOG_WARN,
458
                _log (LOG_WARN,
459
                     "%s: unable to locate tunnel in tunnel list\n",
459
                     "%s: unable to locate tunnel in tunnel list\n",
460
                     __FUNCTION__);
460
                     __FUNCTION__);
461
            }
461
            }
462
        }
462
        }
463
        else
463
        else
464
        {
464
        {
465
            log (LOG_WARN, "%s: tunnel list is empty!\n", __FUNCTION__);
465
            _log (LOG_WARN, "%s: tunnel list is empty!\n", __FUNCTION__);
466
        }
466
        }
467
    }
467
    }
468
    if (t->lac)
468
    if (t->lac)
Lines 471-477 Link Here
471
        if (t->lac->redial && (t->lac->rtimeout > 0) && !t->lac->rsched &&
471
        if (t->lac->redial && (t->lac->rtimeout > 0) && !t->lac->rsched &&
472
            t->lac->active)
472
            t->lac->active)
473
        {
473
        {
474
            log (LOG_LOG, "%s: Will redial in %d seconds\n", __FUNCTION__,
474
            _log (LOG_LOG, "%s: Will redial in %d seconds\n", __FUNCTION__,
475
                 t->lac->rtimeout);
475
                 t->lac->rtimeout);
476
            tv.tv_sec = t->lac->rtimeout;
476
            tv.tv_sec = t->lac->rtimeout;
477
            tv.tv_usec = 0;
477
            tv.tv_usec = 0;
Lines 501-507 Link Here
501
    hp = gethostbyname (host);
501
    hp = gethostbyname (host);
502
    if (!hp)
502
    if (!hp)
503
    {
503
    {
504
        log (LOG_WARN, "%s: gethostbyname() failed for %s.\n", __FUNCTION__,
504
        _log (LOG_WARN, "%s: gethostbyname() failed for %s.\n", __FUNCTION__,
505
             host);
505
             host);
506
        return NULL;
506
        return NULL;
507
    }
507
    }
Lines 514-520 Link Here
514
    tmp = get_call (0, 0, addr, port);
514
    tmp = get_call (0, 0, addr, port);
515
    if (!tmp)
515
    if (!tmp)
516
    {
516
    {
517
        log (LOG_WARN, "%s: Unable to create tunnel to %s.\n", __FUNCTION__,
517
        _log (LOG_WARN, "%s: Unable to create tunnel to %s.\n", __FUNCTION__,
518
             host);
518
             host);
519
        return NULL;
519
        return NULL;
520
    }
520
    }
Lines 530-536 Link Here
530
    /*
530
    /*
531
     * Since our state is 0, we will establish a tunnel now
531
     * Since our state is 0, we will establish a tunnel now
532
     */
532
     */
533
    log (LOG_LOG, "%s:Connecting to host %s, port %d\n", __FUNCTION__, host,
533
    _log (LOG_LOG, "%s:Connecting to host %s, port %d\n", __FUNCTION__, host,
534
         ntohs (port));
534
         ntohs (port));
535
    control_finish (tmp->container, tmp);
535
    control_finish (tmp->container, tmp);
536
    return tmp->container;
536
    return tmp->container;
Lines 542-548 Link Here
542
    lac = (struct lac *) data;
542
    lac = (struct lac *) data;
543
    if (!lac)
543
    if (!lac)
544
    {
544
    {
545
        log (LOG_WARN, "%s: magic_lac_tunnel: called on NULL lac!\n",
545
        _log (LOG_WARN, "%s: magic_lac_tunnel: called on NULL lac!\n",
546
             __FUNCTION__);
546
             __FUNCTION__);
547
        return;
547
        return;
548
    }
548
    }
Lines 559-565 Link Here
559
    }
559
    }
560
    else
560
    else
561
    {
561
    {
562
        log (LOG_WARN, "%s: Unable to find hostname to dial for '%s'\n",
562
        _log (LOG_WARN, "%s: Unable to find hostname to dial for '%s'\n",
563
             __FUNCTION__, lac->entname);
563
             __FUNCTION__, lac->entname);
564
        return;
564
        return;
565
    }
565
    }
Lines 576-582 Link Here
576
            tmp = new_call (t);
576
            tmp = new_call (t);
577
            if (!tmp)
577
            if (!tmp)
578
            {
578
            {
579
                log (LOG_WARN, "%s: unable to create new call\n",
579
                _log (LOG_WARN, "%s: unable to create new call\n",
580
                     __FUNCTION__);
580
                     __FUNCTION__);
581
                return NULL;
581
                return NULL;
582
            }
582
            }
Lines 588-601 Link Here
588
            tmp->lns = lns;
588
            tmp->lns = lns;
589
            if (lac)
589
            if (lac)
590
                lac->c = tmp;
590
                lac->c = tmp;
591
            log (LOG_LOG, "%s: Calling on tunnel %d\n", __FUNCTION__, tid);
591
            _log (LOG_LOG, "%s: Calling on tunnel %d\n", __FUNCTION__, tid);
592
            strcpy (tmp->dial_no, dial_no_tmp); /*  jz: copy dialnumber to tmp->dial_no  */
592
            strcpy (tmp->dial_no, dial_no_tmp); /*  jz: copy dialnumber to tmp->dial_no  */
593
            control_finish (t, tmp);
593
            control_finish (t, tmp);
594
            return tmp;
594
            return tmp;
595
        }
595
        }
596
        t = t->next;
596
        t = t->next;
597
    };
597
    };
598
    log (LOG_DEBUG, "%s: No such tunnel %d to generate call.\n", __FUNCTION__,
598
    _log (LOG_DEBUG, "%s: No such tunnel %d to generate call.\n", __FUNCTION__,
599
         tid);
599
         tid);
600
    return NULL;
600
    return NULL;
601
}
601
}
Lines 606-630 Link Here
606
    lac = (struct lac *) data;
606
    lac = (struct lac *) data;
607
    if (!lac->active)
607
    if (!lac->active)
608
    {
608
    {
609
        log (LOG_DEBUG, "%s: LAC %s not active", __FUNCTION__, lac->entname);
609
        _log (LOG_DEBUG, "%s: LAC %s not active", __FUNCTION__, lac->entname);
610
        return;
610
        return;
611
    }
611
    }
612
    lac->rsched = NULL;
612
    lac->rsched = NULL;
613
    lac->rtries++;
613
    lac->rtries++;
614
    if (lac->rmax && (lac->rtries > lac->rmax))
614
    if (lac->rmax && (lac->rtries > lac->rmax))
615
    {
615
    {
616
        log (LOG_LOG, "%s: maximum retries exceeded.\n", __FUNCTION__);
616
        _log (LOG_LOG, "%s: maximum retries exceeded.\n", __FUNCTION__);
617
        return;
617
        return;
618
    }
618
    }
619
    if (!lac)
619
    if (!lac)
620
    {
620
    {
621
        log (LOG_WARN, "%s : called on NULL lac!\n", __FUNCTION__);
621
        _log (LOG_WARN, "%s : called on NULL lac!\n", __FUNCTION__);
622
        return;
622
        return;
623
    }
623
    }
624
    if (!lac->t)
624
    if (!lac->t)
625
    {
625
    {
626
#ifdef DEGUG_MAGIC
626
#ifdef DEGUG_MAGIC
627
        log (LOG_DEBUG, "%s : tunnel not up!  Connecting!\n", __FUNCTION__);
627
        _log (LOG_DEBUG, "%s : tunnel not up!  Connecting!\n", __FUNCTION__);
628
#endif
628
#endif
629
        magic_lac_tunnel (lac);
629
        magic_lac_tunnel (lac);
630
        return;
630
        return;
Lines 643-649 Link Here
643
        {
643
        {
644
            if (tmp->ourcid == cid)
644
            if (tmp->ourcid == cid)
645
            {
645
            {
646
                log (LOG_LOG,
646
                _log (LOG_LOG,
647
                     "%s :Hanging up call %d, Local: %d, Remote: %d\n",
647
                     "%s :Hanging up call %d, Local: %d, Remote: %d\n",
648
                     __FUNCTION__, tmp->serno, tmp->ourcid, tmp->cid);
648
                     __FUNCTION__, tmp->serno, tmp->ourcid, tmp->cid);
649
                strcpy (tmp->errormsg, "Goodbye!");
649
                strcpy (tmp->errormsg, "Goodbye!");
Lines 655-661 Link Here
655
        }
655
        }
656
        t = t->next;
656
        t = t->next;
657
    };
657
    };
658
    log (LOG_DEBUG, "%s : No such call %d to hang up.\n", __FUNCTION__, cid);
658
    _log (LOG_DEBUG, "%s : No such call %d to hang up.\n", __FUNCTION__, cid);
659
    return;
659
    return;
660
}
660
}
661
661
Lines 666-672 Link Here
666
    {
666
    {
667
        if (t->ourtid == tid)
667
        if (t->ourtid == tid)
668
        {
668
        {
669
            log (LOG_LOG,
669
            _log (LOG_LOG,
670
                 "%s: Disconnecting from %s, Local: %d, Remote: %d\n",
670
                 "%s: Disconnecting from %s, Local: %d, Remote: %d\n",
671
                 __FUNCTION__, IPADDY (t->peer.sin_addr), t->ourtid, t->tid);
671
                 __FUNCTION__, IPADDY (t->peer.sin_addr), t->ourtid, t->tid);
672
            t->self->needclose = -1;
672
            t->self->needclose = -1;
Lines 676-682 Link Here
676
        }
676
        }
677
        t = t->next;
677
        t = t->next;
678
    };
678
    };
679
    log (LOG_DEBUG, "%s: No such tunnel %d to hang up.\n", __FUNCTION__, tid);
679
    _log (LOG_DEBUG, "%s: No such tunnel %d to hang up.\n", __FUNCTION__, tid);
680
    return;
680
    return;
681
}
681
}
682
682
Lines 709-715 Link Here
709
            temp = (int *)entropy_buf;
709
            temp = (int *)entropy_buf;
710
            tmp->ourtid = *temp & 0xFFFF;
710
            tmp->ourtid = *temp & 0xFFFF;
711
#ifdef DEBUG_ENTROPY
711
#ifdef DEBUG_ENTROPY
712
            log(LOG_DEBUG, "ourtid = %u, entropy_buf = %hx\n", tmp->ourtid, *temp);
712
            _log(LOG_DEBUG, "ourtid = %u, entropy_buf = %hx\n", tmp->ourtid, *temp);
713
#endif
713
#endif
714
        }
714
        }
715
#else
715
#else
Lines 773-779 Link Here
773
            if (buf[cnt - 1] == '\n')
773
            if (buf[cnt - 1] == '\n')
774
                buf[--cnt] = 0;
774
                buf[--cnt] = 0;
775
#ifdef DEBUG_CONTROL
775
#ifdef DEBUG_CONTROL
776
            log (LOG_DEBUG, "%s: Got message %s (%d bytes long)\n",
776
            _log (LOG_DEBUG, "%s: Got message %s (%d bytes long)\n",
777
                 __FUNCTION__, buf, cnt);
777
                 __FUNCTION__, buf, cnt);
778
#endif
778
#endif
779
            switch (buf[0])
779
            switch (buf[0])
Lines 781-787 Link Here
781
            case 't':
781
            case 't':
782
                host = strchr (buf, ' ') + 1;
782
                host = strchr (buf, ' ') + 1;
783
#ifdef DEBUG_CONTROL
783
#ifdef DEBUG_CONTROL
784
                log (LOG_DEBUG, "%s: Attempting to tunnel to %s\n",
784
                _log (LOG_DEBUG, "%s: Attempting to tunnel to %s\n",
785
                     __FUNCTION__, host);
785
                     __FUNCTION__, host);
786
#endif
786
#endif
787
                l2tp_call (host, UDP_LISTEN_PORT, NULL, NULL);
787
                l2tp_call (host, UDP_LISTEN_PORT, NULL, NULL);
Lines 801-807 Link Here
801
                        if (!lac->c)
801
                        if (!lac->c)
802
                            magic_lac_dial (lac);
802
                            magic_lac_dial (lac);
803
                        else
803
                        else
804
                            log (LOG_DEBUG,
804
                            _log (LOG_DEBUG,
805
                                 "%s: Session '%s' already active!\n",
805
                                 "%s: Session '%s' already active!\n",
806
                                 __FUNCTION__, lac->entname);
806
                                 __FUNCTION__, lac->entname);
807
                        break;
807
                        break;
Lines 813-824 Link Here
813
                tunl = atoi (tunstr);
813
                tunl = atoi (tunstr);
814
                if (!tunl)
814
                if (!tunl)
815
                {
815
                {
816
                    log (LOG_DEBUG, "%s: No such tunnel '%s'\n", __FUNCTION__,
816
                    _log (LOG_DEBUG, "%s: No such tunnel '%s'\n", __FUNCTION__,
817
                         tunstr);
817
                         tunstr);
818
                    break;
818
                    break;
819
                }
819
                }
820
#ifdef DEBUG_CONTROL
820
#ifdef DEBUG_CONTROL
821
                log (LOG_DEBUG, "%s: Attempting to call on tunnel %d\n",
821
                _log (LOG_DEBUG, "%s: Attempting to call on tunnel %d\n",
822
                     __FUNCTION__, tunl);
822
                     __FUNCTION__, tunl);
823
#endif
823
#endif
824
                lac_call (tunl, NULL, NULL);
824
                lac_call (tunl, NULL, NULL);
Lines 844-850 Link Here
844
                        if (!lac->c)
844
                        if (!lac->c)
845
                            magic_lac_dial (lac);
845
                            magic_lac_dial (lac);
846
                        else
846
                        else
847
                            log (LOG_DEBUG,
847
                            _log (LOG_DEBUG,
848
                                 "%s: Session '%s' already active!\n",
848
                                 "%s: Session '%s' already active!\n",
849
                                 __FUNCTION__, lac->entname);
849
                                 __FUNCTION__, lac->entname);
850
                        break;
850
                        break;
Lines 856-867 Link Here
856
                tunl = atoi (tunstr);
856
                tunl = atoi (tunstr);
857
                if (!tunl)
857
                if (!tunl)
858
                {
858
                {
859
                    log (LOG_DEBUG, "%s: No such tunnel '%s'\n", __FUNCTION__,
859
                    _log (LOG_DEBUG, "%s: No such tunnel '%s'\n", __FUNCTION__,
860
                         tunstr);
860
                         tunstr);
861
                    break;
861
                    break;
862
                }
862
                }
863
#ifdef DEBUG_CONTROL
863
#ifdef DEBUG_CONTROL
864
                log (LOG_DEBUG, "%s: Attempting to call on tunnel %d\n",
864
                _log (LOG_DEBUG, "%s: Attempting to call on tunnel %d\n",
865
                     __FUNCTION__, tunl);
865
                     __FUNCTION__, tunl);
866
#endif
866
#endif
867
                lac_call (tunl, NULL, NULL);
867
                lac_call (tunl, NULL, NULL);
Lines 871-877 Link Here
871
                callstr = strchr (buf, ' ') + 1;
871
                callstr = strchr (buf, ' ') + 1;
872
                call = atoi (callstr);
872
                call = atoi (callstr);
873
#ifdef DEBUG_CONTROL
873
#ifdef DEBUG_CONTROL
874
                log (LOG_DEBUG, "%s: Attempting to call %d\n", __FUNCTION__,
874
                _log (LOG_DEBUG, "%s: Attempting to call %d\n", __FUNCTION__,
875
                     call);
875
                     call);
876
#endif
876
#endif
877
                lac_hangup (call);
877
                lac_hangup (call);
Lines 888-894 Link Here
888
                        if (lac->t)
888
                        if (lac->t)
889
                            lac_disconnect (lac->t->ourtid);
889
                            lac_disconnect (lac->t->ourtid);
890
                        else
890
                        else
891
                            log (LOG_DEBUG, "%s: Session '%s' not up\n",
891
                            _log (LOG_DEBUG, "%s: Session '%s' not up\n",
892
                                 __FUNCTION__, lac->entname);
892
                                 __FUNCTION__, lac->entname);
893
                        break;
893
                        break;
894
                    }
894
                    }
Lines 899-910 Link Here
899
                tunl = atoi (tunstr);
899
                tunl = atoi (tunstr);
900
                if (!tunl)
900
                if (!tunl)
901
                {
901
                {
902
                    log (LOG_DEBUG, "%s: No such tunnel '%s'\n", __FUNCTION__,
902
                    _log (LOG_DEBUG, "%s: No such tunnel '%s'\n", __FUNCTION__,
903
                         tunstr);
903
                         tunstr);
904
                    break;
904
                    break;
905
                }
905
                }
906
#ifdef DEBUG_CONTROL
906
#ifdef DEBUG_CONTROL
907
                log (LOG_DEBUG, "%s: Attempting to disconnect tunnel %d\n",
907
                _log (LOG_DEBUG, "%s: Attempting to disconnect tunnel %d\n",
908
                     __FUNCTION__, tunl);
908
                     __FUNCTION__, tunl);
909
#endif
909
#endif
910
                lac_disconnect (tunl);
910
                lac_disconnect (tunl);
Lines 913-919 Link Here
913
                show_status (1);
913
                show_status (1);
914
                break;
914
                break;
915
            default:
915
            default:
916
                log (LOG_DEBUG, "%s: Unknown command %c\n", __FUNCTION__,
916
                _log (LOG_DEBUG, "%s: Unknown command %c\n", __FUNCTION__,
917
                     buf[0]);
917
                     buf[0]);
918
            }
918
            }
919
        }
919
        }
Lines 986-992 Link Here
986
    int pidfilewritten=0;
986
    int pidfilewritten=0;
987
987
988
    if((pid = fork()) < 0) {
988
    if((pid = fork()) < 0) {
989
        log(LOG_LOG, "%s: Unable to fork ()\n",__FUNCTION__);
989
        _log(LOG_LOG, "%s: Unable to fork ()\n",__FUNCTION__);
990
        close(server_socket);
990
        close(server_socket);
991
        exit(1);
991
        exit(1);
992
    }
992
    }
Lines 1003-1009 Link Here
1003
    if ((i = open(gconfig.pidfile,O_RDONLY)) > 0) {
1003
    if ((i = open(gconfig.pidfile,O_RDONLY)) > 0) {
1004
        l=read(i,buf,sizeof(buf)-1);
1004
        l=read(i,buf,sizeof(buf)-1);
1005
        if (i < 0) {
1005
        if (i < 0) {
1006
            log(LOG_LOG, "%s: Unable to read pid file [%s]\n",
1006
            _log(LOG_LOG, "%s: Unable to read pid file [%s]\n",
1007
                    __FUNCTION__, gconfig.pidfile);
1007
                    __FUNCTION__, gconfig.pidfile);
1008
        }
1008
        }
1009
        buf[i] = '\0';
1009
        buf[i] = '\0';
Lines 1023-1029 Link Here
1023
        }
1023
        }
1024
        else
1024
        else
1025
        {
1025
        {
1026
            log(LOG_LOG, "%s: There's already a l2tpd server running.\n",
1026
            _log(LOG_LOG, "%s: There's already a l2tpd server running.\n",
1027
                    __FUNCTION__);
1027
                    __FUNCTION__);
1028
            close(server_socket);
1028
            close(server_socket);
1029
            exit(1);
1029
            exit(1);
Lines 1053-1064 Link Here
1053
    init_addr ();
1053
    init_addr ();
1054
    if (init_config ())
1054
    if (init_config ())
1055
    {
1055
    {
1056
        log (LOG_CRIT, "%s: Unable to load config file\n", __FUNCTION__);
1056
        _log (LOG_CRIT, "%s: Unable to load config file\n", __FUNCTION__);
1057
        exit (1);
1057
        exit (1);
1058
    }
1058
    }
1059
    if (uname (&uts))
1059
    if (uname (&uts))
1060
    {
1060
    {
1061
        log (LOG_CRIT, "%s : Unable to determine host system\n",
1061
        _log (LOG_CRIT, "%s : Unable to determine host system\n",
1062
             __FUNCTION__);
1062
             __FUNCTION__);
1063
        exit (1);
1063
        exit (1);
1064
    }
1064
    }
Lines 1077-1093 Link Here
1077
    control_fd = open (CONTROL_PIPE, O_RDONLY | O_NONBLOCK, 0600);
1077
    control_fd = open (CONTROL_PIPE, O_RDONLY | O_NONBLOCK, 0600);
1078
    if (control_fd < 0)
1078
    if (control_fd < 0)
1079
    {
1079
    {
1080
        log (LOG_CRIT, "%s: Unable to open " CONTROL_PIPE " for reading.",
1080
        _log (LOG_CRIT, "%s: Unable to open " CONTROL_PIPE " for reading.",
1081
             __FUNCTION__);
1081
             __FUNCTION__);
1082
        exit (1);
1082
        exit (1);
1083
    }
1083
    }
1084
    log (LOG_LOG, "l2tpd version " SERVER_VERSION " started on %s PID:%d\n",
1084
    _log (LOG_LOG, "l2tpd version " SERVER_VERSION " started on %s PID:%d\n",
1085
         hostname, getpid ());
1085
         hostname, getpid ());
1086
    log (LOG_LOG,
1086
    _log (LOG_LOG,
1087
         "Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.\n");
1087
         "Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.\n");
1088
    log (LOG_LOG, "Forked by Scott Balmos and David Stipp, (C) 2001\n");
1088
    _log (LOG_LOG, "Forked by Scott Balmos and David Stipp, (C) 2001\n");
1089
    log (LOG_LOG, "Inhereted by Jeff McAdams, (C) 2002\n");
1089
    _log (LOG_LOG, "Inhereted by Jeff McAdams, (C) 2002\n");
1090
    log (LOG_LOG, "%s version %s on a %s, port %d\n", uts.sysname,
1090
    _log (LOG_LOG, "%s version %s on a %s, port %d\n", uts.sysname,
1091
         uts.release, uts.machine, gconfig.port);
1091
         uts.release, uts.machine, gconfig.port);
1092
    lac = laclist;
1092
    lac = laclist;
1093
    while (lac)
1093
    while (lac)
Lines 1095-1101 Link Here
1095
        if (lac->autodial)
1095
        if (lac->autodial)
1096
        {
1096
        {
1097
#ifdef DEBUG_MAGIC
1097
#ifdef DEBUG_MAGIC
1098
            log (LOG_DEBUG, "%s: Autodialing '%s'\n", __FUNCTION__,
1098
            _log (LOG_DEBUG, "%s: Autodialing '%s'\n", __FUNCTION__,
1099
                 lac->entname[0] ? lac->entname : "(unnamed)");
1099
                 lac->entname[0] ? lac->entname : "(unnamed)");
1100
#endif
1100
#endif
1101
            lac->active = -1;
1101
            lac->active = -1;
(-)l2tpd-0.69/misc.c (-7 / +7 lines)
Lines 30-36 Link Here
30
#include "l2tp.h"
30
#include "l2tp.h"
31
31
32
32
33
void log (int level, const char *fmt, ...)
33
void _log (int level, const char *fmt, ...)
34
{
34
{
35
    char buf[256];
35
    char buf[256];
36
    va_list args;
36
    va_list args;
Lines 99-105 Link Here
99
            c++;                /* again two characters to display ONE byte */
99
            c++;                /* again two characters to display ONE byte */
100
        }
100
        }
101
        *c = '\0';
101
        *c = '\0';
102
        log (LOG_WARN, "%s: buflen=%d, buffer[%d]: *%s*\n", __FUNCTION__,
102
        _log (LOG_WARN, "%s: buflen=%d, buffer[%d]: *%s*\n", __FUNCTION__,
103
             buflen, i, line);
103
             buflen, i, line);
104
    }
104
    }
105
105
Lines 115-121 Link Here
115
    if (c != line)
115
    if (c != line)
116
    {
116
    {
117
        *c = '\0';
117
        *c = '\0';
118
        log (LOG_WARN, "%s:             buffer[%d]: *%s*\n", __FUNCTION__, i,
118
        _log (LOG_WARN, "%s:             buffer[%d]: *%s*\n", __FUNCTION__, i,
119
             line);
119
             line);
120
    }
120
    }
121
}
121
}
Lines 199-205 Link Here
199
    new = (struct ppp_opts *) malloc (sizeof (struct ppp_opts));
199
    new = (struct ppp_opts *) malloc (sizeof (struct ppp_opts));
200
    if (!new)
200
    if (!new)
201
    {
201
    {
202
        log (LOG_WARN,
202
        _log (LOG_WARN,
203
             "%s : Unable to allocate ppp option memory.  Expect a crash\n",
203
             "%s : Unable to allocate ppp option memory.  Expect a crash\n",
204
             __FUNCTION__);
204
             __FUNCTION__);
205
        return NULL;
205
        return NULL;
Lines 265-271 Link Here
265
    if (devrandom == -1)
265
    if (devrandom == -1)
266
    {
266
    {
267
#ifdef DEBUG_ENTROPY
267
#ifdef DEBUG_ENTROPY
268
        log(LOG_WARN, "%s: couldn't open /dev/urandom,"
268
        _log(LOG_WARN, "%s: couldn't open /dev/urandom,"
269
                      "falling back to rand()\n",
269
                      "falling back to rand()\n",
270
                      __FUNCTION__);
270
                      __FUNCTION__);
271
#endif
271
#endif
Lines 288-300 Link Here
288
    }
288
    }
289
    else if (rand_source == RAND_EGD)
289
    else if (rand_source == RAND_EGD)
290
    {
290
    {
291
        log(LOG_WARN, "%s: EGD Randomness source not yet implemented\n",
291
        _log(LOG_WARN, "%s: EGD Randomness source not yet implemented\n",
292
                __FUNCTION__);
292
                __FUNCTION__);
293
        return -1;
293
        return -1;
294
    }
294
    }
295
    else
295
    else
296
    {
296
    {
297
        log(LOG_WARN, "%s: Invalid Randomness source specified (%d)\n",
297
        _log(LOG_WARN, "%s: Invalid Randomness source specified (%d)\n",
298
                __FUNCTION__, rand_source);
298
                __FUNCTION__, rand_source);
299
        return -1;
299
        return -1;
300
    }
300
    }
(-)l2tpd-0.69/misc.h (-1 / +1 lines)
Lines 64-70 Link Here
64
#define halt() printf("Halted.\n") ; for(;;)
64
#define halt() printf("Halted.\n") ; for(;;)
65
65
66
extern char hostname[];
66
extern char hostname[];
67
extern void log (int level, const char *fmt, ...);
67
extern void _log (int level, const char *fmt, ...);
68
extern struct buffer *new_buf (int);
68
extern struct buffer *new_buf (int);
69
extern void udppush_handler (int);
69
extern void udppush_handler (int);
70
extern int addfcs (struct buffer *buf);
70
extern int addfcs (struct buffer *buf);
(-)l2tpd-0.69/network.c (-21 / +21 lines)
Lines 51-57 Link Here
51
    server.sin_port = htons (gconfig.port);
51
    server.sin_port = htons (gconfig.port);
52
    if ((server_socket = socket (PF_INET, SOCK_DGRAM, 0)) < 0)
52
    if ((server_socket = socket (PF_INET, SOCK_DGRAM, 0)) < 0)
53
    {
53
    {
54
        log (LOG_CRIT, "%s: Unable to allocate socket. Terminating.\n",
54
        _log (LOG_CRIT, "%s: Unable to allocate socket. Terminating.\n",
55
             __FUNCTION__);
55
             __FUNCTION__);
56
        return -EINVAL;
56
        return -EINVAL;
57
    };
57
    };
Lines 60-96 Link Here
60
    if (bind (server_socket, (struct sockaddr *) &server, sizeof (server)))
60
    if (bind (server_socket, (struct sockaddr *) &server, sizeof (server)))
61
    {
61
    {
62
        close (server_socket);
62
        close (server_socket);
63
        log (LOG_CRIT, "%s: Unable to bind socket. Terminating.\n",
63
        _log (LOG_CRIT, "%s: Unable to bind socket. Terminating.\n",
64
             __FUNCTION__);
64
             __FUNCTION__);
65
        return -EINVAL;
65
        return -EINVAL;
66
    };
66
    };
67
    if (getsockname (server_socket, (struct sockaddr *) &server, &length))
67
    if (getsockname (server_socket, (struct sockaddr *) &server, &length))
68
    {
68
    {
69
        log (LOG_CRIT, "%s: Unable to read socket name.Terminating.\n",
69
        _log (LOG_CRIT, "%s: Unable to read socket name.Terminating.\n",
70
             __FUNCTION__);
70
             __FUNCTION__);
71
        return -EINVAL;
71
        return -EINVAL;
72
    }
72
    }
73
#ifdef USE_KERNEL
73
#ifdef USE_KERNEL
74
    if (gconfig.forceuserspace)
74
    if (gconfig.forceuserspace)
75
    {
75
    {
76
        log (LOG_LOG, "Not looking for kernel support.\n");
76
        _log (LOG_LOG, "Not looking for kernel support.\n");
77
        kernel_support = 0;
77
        kernel_support = 0;
78
    }
78
    }
79
    else
79
    else
80
    {
80
    {
81
        if (ioctl (server_socket, SIOCSETL2TP, NULL) < 0)
81
        if (ioctl (server_socket, SIOCSETL2TP, NULL) < 0)
82
        {
82
        {
83
            log (LOG_LOG, "L2TP kernel support not detected.\n");
83
            _log (LOG_LOG, "L2TP kernel support not detected.\n");
84
            kernel_support = 0;
84
            kernel_support = 0;
85
        }
85
        }
86
        else
86
        else
87
        {
87
        {
88
            log (LOG_LOG, "Using l2tp kernel support.\n");
88
            _log (LOG_LOG, "Using l2tp kernel support.\n");
89
            kernel_support = -1;
89
            kernel_support = -1;
90
        }
90
        }
91
    }
91
    }
92
#else
92
#else
93
    log (LOG_LOG, "This binary does not support kernel L2TP.\n");
93
    _log (LOG_LOG, "This binary does not support kernel L2TP.\n");
94
#endif
94
#endif
95
    arg = fcntl (server_socket, F_GETFL);
95
    arg = fcntl (server_socket, F_GETFL);
96
    arg |= O_NONBLOCK;
96
    arg |= O_NONBLOCK;
Lines 169-175 Link Here
169
    int ns;
169
    int ns;
170
    if (!buf)
170
    if (!buf)
171
    {
171
    {
172
        log (LOG_WARN, "%s: called on NULL buffer!\n", __FUNCTION__);
172
        _log (LOG_WARN, "%s: called on NULL buffer!\n", __FUNCTION__);
173
        return;
173
        return;
174
    }
174
    }
175
175
Lines 181-187 Link Here
181
        if (ns < t->cLr)
181
        if (ns < t->cLr)
182
        {
182
        {
183
#ifdef DEBUG_CONTROL_XMIT
183
#ifdef DEBUG_CONTROL_XMIT
184
            log (LOG_DEBUG, "%s: Tossing packet %d\n", __FUNCTION__, ns);
184
            _log (LOG_DEBUG, "%s: Tossing packet %d\n", __FUNCTION__, ns);
185
#endif
185
#endif
186
            /* Okay, it's been received.  Let's toss it now */
186
            /* Okay, it's been received.  Let's toss it now */
187
            toss (buf);
187
            toss (buf);
Lines 198-204 Link Here
198
        {
198
        {
199
            if (t->self->needclose)
199
            if (t->self->needclose)
200
            {
200
            {
201
                log (LOG_DEBUG,
201
                _log (LOG_DEBUG,
202
                     "%s: Unable to deliver closing message for tunnel %d. Destroying anyway.\n",
202
                     "%s: Unable to deliver closing message for tunnel %d. Destroying anyway.\n",
203
                     __FUNCTION__, t->ourtid);
203
                     __FUNCTION__, t->ourtid);
204
                t->self->needclose = 0;
204
                t->self->needclose = 0;
Lines 206-212 Link Here
206
            }
206
            }
207
            else
207
            else
208
            {
208
            {
209
                log (LOG_DEBUG,
209
                _log (LOG_DEBUG,
210
                     "%s: Maximum retries exceeded for tunnel %d.  Closing.\n",
210
                     "%s: Maximum retries exceeded for tunnel %d.  Closing.\n",
211
                     __FUNCTION__, t->ourtid);
211
                     __FUNCTION__, t->ourtid);
212
                strcpy (t->self->errormsg, "Timeout");
212
                strcpy (t->self->errormsg, "Timeout");
Lines 223-229 Link Here
223
        tv.tv_usec = 0;
223
        tv.tv_usec = 0;
224
        schedule (tv, control_xmit, buf);
224
        schedule (tv, control_xmit, buf);
225
#ifdef DEBUG_CONTROL_XMIT
225
#ifdef DEBUG_CONTROL_XMIT
226
        log (LOG_DEBUG, "%s: Scheduling and transmitting packet %d\n",
226
        _log (LOG_DEBUG, "%s: Scheduling and transmitting packet %d\n",
227
             __FUNCTION__, ns);
227
             __FUNCTION__, ns);
228
#endif
228
#endif
229
        udp_xmit (buf);
229
        udp_xmit (buf);
Lines 279-285 Link Here
279
            if (st->self->needclose ^ st->self->closing)
279
            if (st->self->needclose ^ st->self->closing)
280
            {
280
            {
281
                if (debug_tunnel)
281
                if (debug_tunnel)
282
                    log (LOG_DEBUG, "%S: closing down tunnel %d\n",
282
                    _log (LOG_DEBUG, "%S: closing down tunnel %d\n",
283
                         __FUNCTION__, st->ourtid);
283
                         __FUNCTION__, st->ourtid);
284
                call_close (st->self);
284
                call_close (st->self);
285
                /* Reset the while loop
285
                /* Reset the while loop
Lines 347-359 Link Here
347
                if (recvsize < 0)
347
                if (recvsize < 0)
348
                {
348
                {
349
                    if (errno != EAGAIN)
349
                    if (errno != EAGAIN)
350
                        log (LOG_WARN,
350
                        _log (LOG_WARN,
351
                             "%s: recvfrom returned error %d (%s)\n",
351
                             "%s: recvfrom returned error %d (%s)\n",
352
                             __FUNCTION__, errno, strerror (errno));
352
                             __FUNCTION__, errno, strerror (errno));
353
                }
353
                }
354
                else
354
                else
355
                {
355
                {
356
                    log (LOG_WARN, "%s: received too small a packet\n",
356
                    _log (LOG_WARN, "%s: received too small a packet\n",
357
                         __FUNCTION__);
357
                         __FUNCTION__);
358
                }
358
                }
359
            }
359
            }
Lines 364-370 Link Here
364
                extract (buf->start, &tunnel, &call);
364
                extract (buf->start, &tunnel, &call);
365
                if (debug_network)
365
                if (debug_network)
366
                {
366
                {
367
                    log (LOG_DEBUG, "%s: recv packet from %s, size = %d,
367
                    _log (LOG_DEBUG, "%s: recv packet from %s, size = %d,\n\
368
tunnel = %d, call = %d\n", __FUNCTION__, inet_ntoa (from.sin_addr), recvsize, tunnel, call);
368
tunnel = %d, call = %d\n", __FUNCTION__, inet_ntoa (from.sin_addr), recvsize, tunnel, call);
369
                }
369
                }
370
                if (packet_dump)
370
                if (packet_dump)
Lines 389-401 Link Here
389
                         * to ack receiving the packet.
389
                         * to ack receiving the packet.
390
                         */
390
                         */
391
                        if (debug_tunnel)
391
                        if (debug_tunnel)
392
                            log (LOG_DEBUG,
392
                            _log (LOG_DEBUG,
393
                                 "%s: no such call %d on tunnel %d.  Sending special ZLB\n",
393
                                 "%s: no such call %d on tunnel %d.  Sending special ZLB\n",
394
                                 __FUNCTION__);
394
                                 __FUNCTION__);
395
                        handle_special (buf, c, call);
395
                        handle_special (buf, c, call);
396
                    }
396
                    }
397
                    else
397
                    else
398
                        log (LOG_DEBUG,
398
                        _log (LOG_DEBUG,
399
                             "%s: unable to find call or tunnel to handle packet.  call = %d, tunnel = %d Dumping.\n",
399
                             "%s: unable to find call or tunnel to handle packet.  call = %d, tunnel = %d Dumping.\n",
400
                             __FUNCTION__, call, tunnel);
400
                             __FUNCTION__, call, tunnel);
401
401
Lines 408-414 Link Here
408
                    if (handle_packet (buf, c->container, c))
408
                    if (handle_packet (buf, c->container, c))
409
                    {
409
                    {
410
                        if (debug_tunnel)
410
                        if (debug_tunnel)
411
                            log (LOG_DEBUG, "%s: bad packet\n", __FUNCTION__);
411
                            _log (LOG_DEBUG, "%s: bad packet\n", __FUNCTION__);
412
                    };
412
                    };
413
                    if (c->cnu)
413
                    if (c->cnu)
414
                    {
414
                    {
Lines 432-438 Link Here
432
                    int result;
432
                    int result;
433
                    recycle_payload (buf, sc->container->peer);
433
                    recycle_payload (buf, sc->container->peer);
434
#ifdef DEBUG_FLOW_MORE
434
#ifdef DEBUG_FLOW_MORE
435
                    log (LOG_DEBUG, "%s: rws = %d, pSs = %d, pLr = %d\n",
435
                    _log (LOG_DEBUG, "%s: rws = %d, pSs = %d, pLr = %d\n",
436
                         __FUNCTION__, sc->rws, sc->pSs, sc->pLr);
436
                         __FUNCTION__, sc->rws, sc->pSs, sc->pLr);
437
#endif
437
#endif
438
/*					if ((sc->rws>0) && (sc->pSs > sc->pLr + sc->rws) && !sc->rbit) {
438
/*					if ((sc->rws>0) && (sc->pSs > sc->pLr + sc->rws) && !sc->rbit) {
Lines 473-479 Link Here
473
                    }
473
                    }
474
                    if (result != 0)
474
                    if (result != 0)
475
                    {
475
                    {
476
                        log (LOG_WARN,
476
                        _log (LOG_WARN,
477
                             "%s: tossing read packet, error = %s (%d).  Closing call.\n",
477
                             "%s: tossing read packet, error = %s (%d).  Closing call.\n",
478
                             __FUNCTION__, strerror (-result), -result);
478
                             __FUNCTION__, strerror (-result), -result);
479
                        strcpy (sc->errormsg, strerror (-result));
479
                        strcpy (sc->errormsg, strerror (-result));
(-)l2tpd-0.69/pty.c (-1 / +1 lines)
Lines 57-62 Link Here
57
            }
57
            }
58
        }
58
        }
59
    }
59
    }
60
    log (LOG_CRIT, "%s: No more free pseudo-tty's\n", __FUNCTION__);
60
    _log (LOG_CRIT, "%s: No more free pseudo-tty's\n", __FUNCTION__);
61
    return -1;
61
    return -1;
62
}
62
}
(-)l2tpd-0.69/scheduler.c (-2 / +2 lines)
Lines 56-62 Link Here
56
    if (cnt != 1)
56
    if (cnt != 1)
57
    {
57
    {
58
        /* Whoa, we got called from within ourselves! */
58
        /* Whoa, we got called from within ourselves! */
59
        log (LOG_DEBUG, "%s : Whoa... cnt = %d\n", __FUNCTION__, cnt);
59
        _log (LOG_DEBUG, "%s : Whoa... cnt = %d\n", __FUNCTION__, cnt);
60
        return;
60
        return;
61
    }
61
    }
62
    while (events)
62
    while (events)
Lines 89-95 Link Here
89
        }
89
        }
90
        if ((then.tv_sec <= 0) && (then.tv_usec <= 0))
90
        if ((then.tv_sec <= 0) && (then.tv_usec <= 0))
91
        {
91
        {
92
            log (LOG_WARN, "%s: Whoa...  Scheduling for <=0 time???\n",
92
            _log (LOG_WARN, "%s: Whoa...  Scheduling for <=0 time???\n",
93
                 __FUNCTION__);
93
                 __FUNCTION__);
94
        }
94
        }
95
        else
95
        else

Return to bug 40859