Lines Matching refs:p
239 static int rose_parse_national(unsigned char *p, struct rose_facilities_struct *facilities, int len) in rose_parse_national() argument
246 switch (*p & 0xC0) { in rose_parse_national()
250 p += 2; in rose_parse_national()
258 if (*p == FAC_NATIONAL_RAND) in rose_parse_national()
259 facilities->rand = ((p[1] << 8) & 0xFF00) + ((p[2] << 0) & 0x00FF); in rose_parse_national()
260 p += 3; in rose_parse_national()
268 p += 4; in rose_parse_national()
276 l = p[1]; in rose_parse_national()
279 if (*p == FAC_NATIONAL_DEST_DIGI) { in rose_parse_national()
283 memcpy(&facilities->source_digis[0], p + 2, AX25_ADDR_LEN); in rose_parse_national()
287 else if (*p == FAC_NATIONAL_SRC_DIGI) { in rose_parse_national()
291 memcpy(&facilities->dest_digis[0], p + 2, AX25_ADDR_LEN); in rose_parse_national()
295 else if (*p == FAC_NATIONAL_FAIL_CALL) { in rose_parse_national()
298 memcpy(&facilities->fail_call, p + 2, AX25_ADDR_LEN); in rose_parse_national()
300 else if (*p == FAC_NATIONAL_FAIL_ADD) { in rose_parse_national()
303 memcpy(&facilities->fail_addr, p + 3, ROSE_ADDR_LEN); in rose_parse_national()
305 else if (*p == FAC_NATIONAL_DIGIS) { in rose_parse_national()
311 for (pt = p + 2, lg = 0 ; lg < l ; pt += AX25_ADDR_LEN, lg += AX25_ADDR_LEN) { in rose_parse_national()
323 p += l + 2; in rose_parse_national()
328 } while (*p != 0x00 && len > 0); in rose_parse_national()
333 static int rose_parse_ccitt(unsigned char *p, struct rose_facilities_struct *facilities, int len) in rose_parse_ccitt() argument
339 switch (*p & 0xC0) { in rose_parse_ccitt()
343 p += 2; in rose_parse_ccitt()
351 p += 3; in rose_parse_ccitt()
359 p += 4; in rose_parse_ccitt()
367 l = p[1]; in rose_parse_ccitt()
373 if (*p == FAC_CCITT_DEST_NSAP) { in rose_parse_ccitt()
374 memcpy(&facilities->source_addr, p + 7, ROSE_ADDR_LEN); in rose_parse_ccitt()
375 memcpy(callsign, p + 12, l - 10); in rose_parse_ccitt()
379 if (*p == FAC_CCITT_SRC_NSAP) { in rose_parse_ccitt()
380 memcpy(&facilities->dest_addr, p + 7, ROSE_ADDR_LEN); in rose_parse_ccitt()
381 memcpy(callsign, p + 12, l - 10); in rose_parse_ccitt()
385 p += l + 2; in rose_parse_ccitt()
390 } while (*p != 0x00 && len > 0); in rose_parse_ccitt()
395 int rose_parse_facilities(unsigned char *p, unsigned packet_len, in rose_parse_facilities() argument
400 facilities_len = *p++; in rose_parse_facilities()
405 while (facilities_len >= 3 && *p == 0x00) { in rose_parse_facilities()
407 p++; in rose_parse_facilities()
409 switch (*p) { in rose_parse_facilities()
411 len = rose_parse_national(p + 1, facilities, facilities_len - 1); in rose_parse_facilities()
415 len = rose_parse_ccitt(p + 1, facilities, facilities_len - 1); in rose_parse_facilities()
419 printk(KERN_DEBUG "ROSE: rose_parse_facilities - unknown facilities family %02X\n", *p); in rose_parse_facilities()
429 p += len + 1; in rose_parse_facilities()
437 unsigned char *p = buffer + 1; in rose_create_facilities() local
444 *p++ = 0x00; in rose_create_facilities()
445 *p++ = FAC_NATIONAL; in rose_create_facilities()
448 *p++ = FAC_NATIONAL_RAND; in rose_create_facilities()
449 *p++ = (rose->rand >> 8) & 0xFF; in rose_create_facilities()
450 *p++ = (rose->rand >> 0) & 0xFF; in rose_create_facilities()
456 *p++ = FAC_NATIONAL_DIGIS; in rose_create_facilities()
457 *p++ = AX25_ADDR_LEN * (rose->source_ndigis + rose->dest_ndigis); in rose_create_facilities()
461 memcpy(p, &rose->source_digis[nb], AX25_ADDR_LEN); in rose_create_facilities()
462 p[6] |= AX25_HBIT; in rose_create_facilities()
463 p += AX25_ADDR_LEN; in rose_create_facilities()
468 memcpy(p, &rose->dest_digis[nb], AX25_ADDR_LEN); in rose_create_facilities()
469 p[6] &= ~AX25_HBIT; in rose_create_facilities()
470 p += AX25_ADDR_LEN; in rose_create_facilities()
476 *p++ = FAC_NATIONAL_SRC_DIGI; in rose_create_facilities()
477 *p++ = AX25_ADDR_LEN; in rose_create_facilities()
478 memcpy(p, &rose->source_digis[0], AX25_ADDR_LEN); in rose_create_facilities()
479 p += AX25_ADDR_LEN; in rose_create_facilities()
484 *p++ = FAC_NATIONAL_DEST_DIGI; in rose_create_facilities()
485 *p++ = AX25_ADDR_LEN; in rose_create_facilities()
486 memcpy(p, &rose->dest_digis[0], AX25_ADDR_LEN); in rose_create_facilities()
487 p += AX25_ADDR_LEN; in rose_create_facilities()
491 *p++ = 0x00; in rose_create_facilities()
492 *p++ = FAC_CCITT; in rose_create_facilities()
494 *p++ = FAC_CCITT_DEST_NSAP; in rose_create_facilities()
498 *p++ = strlen(callsign) + 10; in rose_create_facilities()
499 *p++ = (strlen(callsign) + 9) * 2; /* ??? */ in rose_create_facilities()
501 *p++ = 0x47; *p++ = 0x00; *p++ = 0x11; in rose_create_facilities()
502 *p++ = ROSE_ADDR_LEN * 2; in rose_create_facilities()
503 memcpy(p, &rose->dest_addr, ROSE_ADDR_LEN); in rose_create_facilities()
504 p += ROSE_ADDR_LEN; in rose_create_facilities()
506 memcpy(p, callsign, strlen(callsign)); in rose_create_facilities()
507 p += strlen(callsign); in rose_create_facilities()
509 *p++ = FAC_CCITT_SRC_NSAP; in rose_create_facilities()
513 *p++ = strlen(callsign) + 10; in rose_create_facilities()
514 *p++ = (strlen(callsign) + 9) * 2; /* ??? */ in rose_create_facilities()
516 *p++ = 0x47; *p++ = 0x00; *p++ = 0x11; in rose_create_facilities()
517 *p++ = ROSE_ADDR_LEN * 2; in rose_create_facilities()
518 memcpy(p, &rose->source_addr, ROSE_ADDR_LEN); in rose_create_facilities()
519 p += ROSE_ADDR_LEN; in rose_create_facilities()
521 memcpy(p, callsign, strlen(callsign)); in rose_create_facilities()
522 p += strlen(callsign); in rose_create_facilities()
524 len = p - buffer; in rose_create_facilities()