James Kuszmaul | 82f6c04 | 2021-01-17 11:30:16 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file cseq.c SIP CSeq decode |
| 3 | * |
| 4 | * Copyright (C) 2010 Creytiv.com |
| 5 | */ |
| 6 | #include <re_types.h> |
| 7 | #include <re_fmt.h> |
| 8 | #include <re_mbuf.h> |
| 9 | #include <re_uri.h> |
| 10 | #include <re_list.h> |
| 11 | #include <re_sa.h> |
| 12 | #include <re_msg.h> |
| 13 | #include <re_sip.h> |
| 14 | |
| 15 | |
| 16 | /** |
| 17 | * Decode a pointer-length string into a SIP CSeq header |
| 18 | * |
| 19 | * @param cseq SIP CSeq header |
| 20 | * @param pl Pointer-length string |
| 21 | * |
| 22 | * @return 0 for success, otherwise errorcode |
| 23 | */ |
| 24 | int sip_cseq_decode(struct sip_cseq *cseq, const struct pl *pl) |
| 25 | { |
| 26 | struct pl num; |
| 27 | int err; |
| 28 | |
| 29 | if (!cseq || !pl) |
| 30 | return EINVAL; |
| 31 | |
| 32 | err = re_regex(pl->p, pl->l, "[0-9]+[ \t\r\n]+[^ \t\r\n]+", |
| 33 | &num, NULL, &cseq->met); |
| 34 | if (err) |
| 35 | return err; |
| 36 | |
| 37 | cseq->num = pl_u32(&num); |
| 38 | |
| 39 | return 0; |
| 40 | } |